How to Migrate Your WordPress Site from Localhost to Live Server

Category: Software Install and Setup

Building a WordPress site locally is a great way to develop and test your website before making it live. However, once everything is ready, you'll need to migrate your site from localhost to a live server. This guide will walk you through the process step by step.

1. Choose a Hosting Provider and Set Up Your Live Server

Before migration, you need a hosting provider. Some popular choices include:

Once you've purchased a hosting plan, set up your domain and access your cPanel or server dashboard.

2. Export Your WordPress Database from Localhost

You'll need to export your WordPress database using phpMyAdmin:

  1. Open phpMyAdmin on your local server.
  2. Select your WordPress database.
  3. Click Export and choose the SQL format.
  4. Download the database file.

3. Upload WordPress Files to Your Live Server

Transfer your WordPress files to the live server using FTP:

  • Use an FTP client like FileZilla.
  • Connect to your server using FTP credentials.
  • Navigate to the public_html folder (or your domain's root directory).
  • Upload all files from your local WordPress directory.

4. Create a New Database on Your Live Server

To import your database, first, create a new database on your live server:

  1. Log in to your cPanel.
  2. Go to MySQL Databases and create a new database.
  3. Create a new database user and assign it full privileges.

5. Import Your Database to the Live Server

Now, import your database:

  • Open phpMyAdmin on your live server.
  • Select the newly created database.
  • Click Import and upload the SQL file you exported earlier.

6. Update wp-config.php

Edit the wp-config.php file to match your new database credentials:

define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');

7. Update URLs in the Database

Update site URLs to match your live domain:

UPDATE wp_options SET option_value = 'http://yourlivesite.com' WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'http://yourlivesite.com' WHERE option_name = 'home';

8. Set Up Permalinks and Test Your Site

After migration, update permalinks:

  • Go to WordPress Admin > Settings > Permalinks.
  • Save changes to regenerate permalinks.
  • Test your site to ensure everything works.

Conclusion

Migrating your WordPress site from localhost to a live server is easy when following these steps. By ensuring proper database import, file transfer, and URL updates, your site will be live in no time. For more help, visit the official WordPress support page.