Moving a WordPress site from local to live

Nov 22, 2012 by

This entry was written by , one of the OxonDigital members. The author's views below are entirely their own and may not reflect the views of OxonDigital.
Moving a WordPress site from local to live

As a follow up to my previous post on Setting up a WordPress local development environment, the next step is Moving a WordPress site from local to live. You have your site just as you want it locally, and and would like to see exactly the same on your live server. The first step is to find yourself a WordPress host, I use names.co.uk but there are plenty to choose from here. I wanted to make sure my local site stayed exactly as it was for further development, no messing with its .config files etc so decided to work from a back up, and upload from there. Its taken me a while to develop a process I am comfortable with, and this approach now works for me, so here goes …

Step 1 – Back up your files

Setup a separate folder on your desktop called ‘yoursitename_backup’ and copy the entire contents of your local ‘wordpress’ (or alternatively named) folder to here. In my case the files are in MAMP / htdocs / wordpress.

Step 2 – Back up your database

Go to your local pHpMyAdmin (via MAMP Welcome Screen)

Click on the database name in the left hand column

Click on the Export tab and select ‘all files’ for export

Check ‘Save as File’ and then ‘Go’ to export a .sql file

Put this in your backup folder

Step 3 – Setup a Database on your host

Login to you hosts control panel and navigate to your MySQL Databases. ( In my case – CP > Domain Names > yoursite.co.uk > MySQLDatabases)

Add a database and enter your details for Name, Password and Username (you will need these details later to edit your config.php so take a note of them including the name of your MySQL Server.)

Select your new database and login via phpMyAdmin, click on your database name in the left column.

Click on the import tab then browse to locate your exported database in your backup folder, select and import.

Once imported, you will see the wordpress tables appear in the left column, and details of those tables in the main area.

database

Step 4 – Edit your host database

Congratulations, you now have all your WordPress content in your database, content for post pages etc. We now need to edit two values in your database tables as they currently reference your local database. To do this you.

Click on wp-options in the left column, then click on the browse tab to see details of this database table.

Find ‘siteurl‘ in the ‘option_name’ column and change your ’option_value’ from localhost:8888 to http://yoursite.co.uk

Find ‘home’ in the ‘option_name’ column, and change the ‘option_value’ from localhost:8888 to http://yoursite.co.uk

Step 5 – Point WordPress to the new database

Find your config.php file within your WordPress files in your backup folder and open in a text editor. This will currently be pointing to you local sites database. Edit the details to correspond with your new database login details. These are the details that you have recorded above, or you can check with you host if you are unsure.

define(‘DB_NAME’, ‘database_name’);
define(‘DB_USER’, ‘database_user’);
define(‘DB_PASSWORD’, ‘database_password’);
define(‘DB_HOST’, ‘mysql7.yourhost.net’);

Step 6 – Copy your WordPress site to live

FTP all your WordPress files from your backup folder to the root folder of your live site via your preferred ftp method – this takes a while.

Step 7 – Search and Replace URLs

Finally – there will be references in your database for image paths etc that will need to be changed for everything to display correctly. I have used this script to Search and replace all urls in database. Take care with it and make sure you delete if afterwards, there are step by step instructions on the website, but basically you rename it, add it to your root folder, access it via http://yoursite.co.uk/yourscriptname.php and follow the prompts.

http://interconnectit.com/124/search-and-replace-for-wordpress-databases/

Step 8 – Check your live site

Everything should now be up and running, check your site and access via admin (http://www.yoursite.co.uk/admin) – login with the same login details as your local site.

WordPress also has details here of how to move sites http://codex.wordpress.org/Moving_WordPress. There may be other ways of doing this and in the end its about finding a process that you are comfortable with. I hope this helps someone that is going through the same process and any suggestions for other ways, extra information, things I may have missed etc are very very welcome.

Define Media - Creative web and graphic design services. Follow Maria on Google Plus.

2 Comments

  1. Hi Maria nice blog post. I have found a useful plugin which can perform these tasks (which if you mess one up, it can be frustrating), I have used it multiple times without issues.

    http://wordpress.org/extend/plugins/duplicator/

  2. Hi Shannon, I can’t wait to try this plug in out on my next site move! I’m kind of glad to know the process involved now, but anything that can automate it brilliant. Thanks for both the comment and the link. Do you have any other plug-ins that you recommend ?

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close