How to create a local copy of a wordpress site
This article explains how you set up a copy of a WordPress site on your computer. This can be very useful if you need to find out what will happen if you do an upgrade, for testing out and playing with plug ins, and for developing WordPress themes.
This article is aimed at PC owners. I use both PC and Mac, and this time I had to do this task on my PC. The principles can also be applied to a Mac, and I have already written a group of articles for Mac which will be linked to from this article that achieve the same results.
We’ll be going through the following steps:
- Installing PHP, MySQL and Apache on a PC to form the ‘local host’
- Copying the WordPress install over from your remote host
- Copying the database
Here we go…
Installing PHP, MySQL and Apache
Mac users
Go to my tutorial on setting up PHP, MySQL and Apache on a Mac.
PC users
There are many packages available that allow a one click installation of PHP, MySQL and Apache on a PC. I looked at a few and settled for WAMP, as its kept up to date, is relatively lightweight and easy to use.
- Start by downloading WAMP.
- Run through the installation, accepting the defaults.
- You should now see a new icon in your taskbar – that’s WAMP! If you don’t see it, just start the software by clicking on the icon, or locating it in your programs.
- Start your webserver by left clicking on the icon in the taskbar, and selecting Start All Services. Nothing will happen – the services run behind the scenes.
- Open a browser and go to http://localhost/, if you see the WampServer homepage then you’re ready to start setting up wordpress.
Copying the WordPress install over from your remote host
Next you are going to download WordPress from your remote host and set it up as a local site.
- Using your preferred FTP client (I use the excellent free filezilla) download all the files in and including the folder associated with your WordPress install. If your WordPress is in a folder called ‘wordpress’, you need to download the whole folder.
- Place the downloaded folder into the WAMP folder www. This is where all files to be run on the webserver need to be placed. This can be found by clicking the WAMP icon and selecting the ‘www’ directory option. Its also in C:/wamp/www
- Once the downloads are complete, go to http://localhost/the_name_of_your_wordpress_folder, you should see a database error. If you do, its all worked! If you see a server error, its likely to be your .htaccess file – try removing it temporarily.
Copying the database
Now you need to get all the tables associated with WordPress out of the remote server, and onto the local server. You’ll probably need to use PHP MyAdmin, which most hosts include by default. If this isn’t available and your using a version of WordPress which is later than 2.0.3 you can try the wordpress db backup plugin.
- Log in to PhpMyAdmin
- Select the database containing your WordPress tables, note down its name
- Select the Export Option
- Select all the tables related to this WordPress installation
- Ensure you download as SQL, check the Data box, so all data is downloaded – complete and extended inserts. Check the box so you save as file and select no compression (it sometimes goes wrong).
Next you need to import this data into phpMyAdmin on your local WAMP server.
- Start PhpMyAdmin by clicking on the WAMP icon and selecting the option phpMyAdmin
- On the homepage there is an option called ‘Create New Database’, enter the name of the database from your remote server and click create.
- Click on your newly created database in the left hand column.
- Click import and browse to your downloaded file
- Click ‘go’ and all the data should be imported
- If you have problems with the size of your datafile, there are other methods – send me a mail, or add a comment and I’ll go into them. At the moment I’m trying to keep this document as simple as I can.
Next you need to set up the same username and password on this local database as is used on your remote database. You will have used these to log in to phpMyAdmin on your remote server, they are also in your wp_config file.
- Go to the homepage of the local phpMyAdmin and select ‘Privileges’
- Click the add a new user option
- Under username enter the username from the remote host, under host select localhost, under password and re-type enter the password from the remote host. Under privileges check all. Click go.
A note on user permissions – I had some issues with the host type – basically, in the wp-config file you need to check the DB_HOST entry. If the host is ‘localhost’ the user in the local mySQL should be set to host – localhost. If the host is ’127.0.0.1′ the user should be set to host – any.
Finally, you need to change a couple of fields inside the wordpress database to ensure the correct web address is used.
- Go to the local phpMyAdmin
- Select the database containing wordpress
- Select the table wp_options
- Select browse
- Locate the option ‘siteurl’ and edit it so the option_value becomes http://localhost/local_folder_name
- Locate the option ‘home’ and edit it so the option_value becomes http://localhost/local_folder_name (this might be on the second page of database fields).
And you should now be done check http://localhost/local_folder_name.
Whats Next
Keep an eye out for many more WordPress tutorials over the coming weeks. I’m currently freelancing and am working on a bunch of WordPress sites for various people, as well as working on some open source themes, premium themes and plug-ins. Email me if you need any assistance – kirby [dot] mark [at] gmail [dot] com.


23 Comments
inspirationbit
Thanks so much for this post, Mark. I didn’t know about the last part with the changes for the siteurl and home, and these are so important.
liam
Nice one man, think I might give this a try. Nice work!
chris
so frustrated…i’ve changed my ‘siteurl’ and ‘home’; however, when i navigate to my site on localhost i get a 404 not found error…
the odd thing is it points to the .com address of the live site, but the folder name on localhost…obviously, i’ve done something wrong…but i can’t fathom what…
any ideas?
Browser Media
Just wanted to say thank you for a superb summary of this process. I am just about to update our site (built on wordpress but not touched for a couple of years and long overdue an overhaul) and wanted to set up a local environment. Very useful article and much appreciated!
Migrating a hosted WordPress site to your local PC :: ITauthor
[...] http://mark-kirby.co.uk/2008/how-to-create-a-local-copy-of-a-wordpress-site/ [...]
John
A note on user permissions – I had some issues with the host type – basically, in the wp-config file you need to check the DB_HOST entry. If the host is ‘localhost’ the user in the local mySQL should be set to host – localhost. If the host is ‘127.0.0.1? the user should be set to host – any.
Sir, could you explain what the above text means?
Demers Designs
Great write up. I would like to add one more step that may or may not be necessary. If you are using a custom permalink structure, your links to individual posts and categories may not work when you bring your site to a local server. I have found that if you switch the permalinks back to default, save, and then go back to your custom settings, it should work fine. I assume it is something about the .htaccess file not copying from the live server. Hope this helps someone…
Dave
Thanks for the complete and easy to follow guide, now I have a working localhost and time to modify my templates. Thanks for this great guide! Keep it up
eggplant64
Amazing! I’ve been having such a headache with this and then came across this page. Completely resolved all the issues I was having. Thanks you!
Lynn
Kudos to you, Mark! This is the best explanation (and I took a good look at several) and the only trouble I had was just discovering (thanks to the Demers Designs comment) that I needed to set the permalinks to the default.
Brilliant! Now I can demo a blog for an organization that won’t have an internet connection for our meeting.
Marcela
Thank you so much for your tutorial. I was able to set up everything with no problems. I still have some glitches to solve but at least I now have a local copy of my site to play around with.
This was great help
Paul Kiddie’s Blog : HTTP Server error 500 Wordpress
[...] a staging production server, again using a SVN checkout. I’ve been using a great tutorial at “http://mark-kirby.co.uk/2008/how-to-create-a-local-copy-of-a-wordpress-site/ to copy WordPress installs and it deals well with the issues concerning moving WordPress installs [...]
Michael Soriano
thank you for this. very clear and easy to follow.
Warren
Thanks Mark!
Been looking everywhere and this is the first place mentioning the changes for the siteurl and home. And that did it!
Ryan Erwin
Some people would prefer not update the database content every time they copy the database from Live back to their local system for development.
The WordPress Developer Site has some documentation on patching the wp-includes/functions.php file to avoid any SQL changes when reloading the database.
Running a Development Copy of WordPress at codex.developer.com.
—
Ryan Erwin
Shanghai, China
milesj
Seemed so simple, however, when I followed all the steps and went to URL localhost:8888/wordpress (I’m running MAMP), the browser window is just blank. Similarly if I go to wp-login.php and login the screen browser remains blank.
sara
Excellent write-up. I have problems when trying to import my database as the file is too big. How can I get around this issue?
Many thanks
Beri
Great guideline, many thanks!!
I did have a problem though. The homepage was showing correctly on localhost, but clicking on any post or page resulted in an ‘cannot find url’ error. I finally found out how to resolve it:
Go to http://localhost/portal/wp-admin/options-permalink.php and change the setting to default.
Takis Vakatasis
hello Mark
thank you so much for this detailed step by step guide…..i follow your steps and finally i made my wordpress theme working locally (my site is: http://www.judo.com.gr)
Best Regards
Takis
darkhoro
OHH MAANNN thanks a lot, you helped me a lot !
P.S : for people who use easyphp, put http://127.0.0.1:8888/folder_name in siteurl and home.
Damian Saunders
Hi Mark,
Thanks so much, I’d been frustrated with this for a while now and other tutorials don’t cover the php Admin steps like you did.
Still have a couple of glitches with images using fully qualified URLs etc but there’s enough to develop and test.
Cheers
Damian
http://www.damiansaunders.net
Ramon
Hi! I have followed all the steps and the main page loads at http://localhost.
However, when I click on any post or page, all I get are “Not found” errors.
I have the Permalinks plugin by John Bloch installed and this is what is causing the problem. I changed the Permalink settings to default and now I can browse.
However, this is not satisfactory since I do need to use the Permalinks once I’m done working on http://localhost and implement the changes to the live site.
Can you or anyone here point me to the right direction on how to make permalinks work on http://localhost?
Fabrice
Thank you so much for this tutorial. Great great stuff!