Hosting Tutorial & Guide

How to Migrate Local WordPress to a Live Server?

updated on Mar 05, 2015
How to Migrate Local WordPress to a Live Server? Usually, developing a WordPress site on a virtual web server that has been installed locally can save you much efforts and time on a day to day basis. Many webmasters choose to finish all WordPress developments on a localhost before uploading their websites to a live server as it is fairly annoying to save and refresh every edit on a live environment.

At this place, we would like to walk you through the following up-to-date steps to migrate all of your site's content and themes as well as plugins to a production server. Now, let's get down to the key point.

Some Prerequisites You Need to Know

Before we start, there are some pre-steps that need to be noted. The first thing you need to ensure is the local server. In this tutorial, we assume that you have WordPress installed on your local computer, and in the meantime, have full root to a local server.

And then, you shall make sure that your web host provides the latest cutting-edge technology as your local environment so as the WordPress site has no compatibility issue after deploy live.

To be frank, there are a bunch of WordPress hosting providers currently, but it is a painstaking task to pick out a high-quality solution that is well worth the price. Having compared numerous web hosts on the market, we select out those best WordPress hosting that are feature-rich and budget-friendly.



Apart from that, you might get to know how to use a FTP program properly in order to upload your pages, posts, images and other content to a live site. Special attention should be paid that we would like to take the example of cPanel admin panel in the following parts.

Move Local WordPress to Live

At the very beginning, you'd better backup the database and all of your WordPress content, including images, directories and plugins, etc. To be frank, it's not as complicated as it sounds, and we would like to explain how to make a copy of your local WP database in detail as follows.

Step 1 – Export and Copy Your Database File
To do so, you should login to cPanel so as to manage all of your site files. If done, all you need to do is to click on the "phpMyAdmin" icon in the "Databases" section. Alternatively, you can choose to type http://localhost/phpmyadmin in your address bar to enter your WordPress database. If you know little about the use of phpMyAdmin, it is highly recommendable to read this guide firstly.

Export and Copy Your Database File

If everything goes right, you will be presented with all of the tables on your local WordPress site as is showed above. Here, click the "Export" button on the top menu bar and you will be prompted to choose the "Export Method", including "Quick" and "Custom." And then, select your preferred export method and specify the file format from the drop-down menu.

Choose Your Export Method

At this place, we would like to choose the "Quick" method to display only minimal options and save those ready-to-export files as ".sql" format. And finally, click on "Go" button and you will have a copy of your local database files.

Step 2 – Modify Your File Paths
If you set up your WordPress site locally, it is likely that all of the links to content files (like images, post types and posts) would begin with http://localhost/. In this case, it is recommendable to change your link structure so as to display your content properly.

To do this, you might need to use a text editor to open and check the previously-exported database files. For instance, you can choose to open the exported files with the "Notepad++" code editor and use the "Search and Replace" feature to replace the old path like http://mywordpress.loc with the new one like http://mywordpress.com.

Modify Your File Paths

Note that, you'd better not use a default text editor like "Notepad" in Windows OS in case for unnecessary screwy things from large files. And once you have done this modification, you should save and close right now. Do not attempt to change anything else.

Step 3 – Create Your New Database
Next, you should build up a new database on your hosting to have your files uploaded to the live environment. To do that, you will need to setup a database in cpanel by navigating to "MySQL Databases" icon in the above-mentioned "Databases" section. Once entered, you will be asked to fill in a new database name in the blank box.

Create Your New Database

In the meantime, you can still create and add new MySQL users to the newly-created database by entering username and password. If done, you will be required to set different MySQL privileges for different purposes.

Create Your MySQL Users

Step 4 – Import the Database Files
Having set up a new and empty database on your live server, it is time to import your own database files. To do this, you would go back to the interface of phpMyAdmin and click on the "Import" button. And next, browse and select the ".sql" database files that have been saved on your computer.

Import the Database Files

Step 5 – Upload Local WordPress Files
After that, you would need to upload your local WordPress files to live server. In terms of the details, you shall take advantage of an FTP client so as to get connected to your hosting server. And then, browse to the public_html, www or any folder where you plan to have your WordPress site installed.

Upload Local WordPress Files

As is displayed, you would select all of your WordPress files and "Upload" them to the live server.

Step 6 – Configure the wp-config.php File
If you are notified with a message saying "Error establishing a database connection", chances are that the credentials of your MySQL database have been changed. To avoid this embarrassing situation, you should configure the wp-config.php file in a text editor. Here are some details that you need to modify.

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

Note that all those settings should be changed in accordance with the previously-filled information in the Step 3. Also, it is probable to change your MySQL host name by the specific instructions from your web host.

Step 7 – Specify Permalinks and Fix Broken Links
Last but not the least, you will have to modify your new site's link structure so as to fit well with your old site. As for details, you only need to login to the WordPress dashboard and go to "Settings" > "Permalinks." In the following screenshot, you are allowed to choose the very permalink structure of your local site and put all changes into effect by clicking "Save Changes."

Specify Permalinks and Fix Broken Links

In the further, you still have to check and remove broken links that may affect your site traffic in a negative way. If needed, you'd better check broken images and anything else to make sure your site is working as expected. Till this step, your WordPress site will be live now.