Moving WordPress from localhost to live production

Moving a WordPress site over from one server to another server or copying the site from your test server to a live production server can be downright confusing.

WordPress provides some solutions and there are a few good plugins around that do the trick but I wanted to figure this out for myself right from scratch. Not use any plugins or import tools.

Follow these steps to move your site between servers when there is a name change. For example moving from the localhost testing computer to the live production site. The same could be said for the reverse: from a live site to your localhost machine.

Caution: This is for developers. If you don’t like changing code and running MySQL commands then stop reading this now. Also: You might have changed the prefix of the table names to something like ‘mysite_posts’ when you first installed WordPress. The default when I installed WordPress was ‘wp_’. So change the code below as necessary.

    1. In the root of the directory you will see a file called “wp-config.php”. Make sure you set the database settings to the correct username and password. This make sure you are connected to the right database. Make the necessary changes if needed.
    2. Make sure you don’t put in define methods for “WP_HOME” and “WP_SITEURL” in the “wp-config.php” file like this:

      If they are there remove them.

    3. In the database there is a table called “wp_options”. Make sure the “siteurl” (option_name) is set to your real URL “” (option_value). This makes sure your site url is set right.
    4. In the database there is a table called “wp_options”. Make sure the “home” (option_name) is set to your real URL “” (option_value). This makes sure your home url is set right.
    5. You might experience posts that are still accessing previous servers or developer testing computers. You can run a database command on the “wp_posts” table to fix this. For example you might see “http://localhost/testsite…” in the “guid” column. This needs to be changed to “…”. Below is the MySQL code you need to run to fix this.The format for the code is as follows:
       update `wp_posts` set `guid` = replace(guid, ’STRING_YOU_WANT_CHANGED', ‘NEW_STRING’)

      A real example of this would be:

       update `wp_posts` set `guid` = replace(guid, 'http://localhost/testsite', '')

      This is basically a MySQL replace command.

      You may want to check this periodically when developers do updates or changes to your site.

    6. Whenever you make guid changes go into the back-end admin (“wp-admin”) page, click on “Settings” then click on “Permalinks”. Do not make any changes but click on “Save Changes”. This helps to reset any settings to the url scheme.

For further reading and just to be fair WordPress has an article on moving sites over: I might be a bit biased but I find mine easier to follow. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *