There are cases where having and running your complete wordpress site offline in your local machine can be useful:
1) To run as a backup.
2) To write a new theme just for your site.
3) To test out new plugins before you plug it into your real live wordpress (online) site.
3) To talk to yourself where no one cares what you say, and reply to your own comments if you wish
4) and best of all, to mess with the database with phpmyadmin.
1. First of all, you need to backup all the contents of your live wordpress site using the WordPress Database backup plugin (Read my Top 10 Most Wanted WordPress Plugins)
* I would recommend the core wordpress tables to be backup only, namely:
– wp_comments
– wp_links
– wp_options
– wp_postmeta
– wp_posts
– wp_term_relationships
– wp_term_taxonomy
– wp_terms
– wp_usermeta
– wp_users
2. Get yourself a copy of Xampp. I use the lite version personally, but you can get the full version if you want. Extract it into C:\ (assuming you’re using windows)
3. Install wordpress into C:\xampp\htdocs\wplocal (or anything you like in C:\xampp\htdocs\)
4. Start xampp. Using your browser, goto http://localhost/phpmyadmin. Create a new database (ex. wplocal)
5. Import the SQL script created from step 1 into the database you’ve just created (ex. wplocal) from phpmyadmin
6. Edit wp-config.php so the local wordpress knows which database it will be using.
7. This part is important
Up till this stage, all we’ve done is getting our data from our live site into a database stored locally. The site is already runnable locally, but you need to change these 3 fields in the wp_options table (to ensure you won’t be directed back to your live site when you test locally):
– siteurl
– home
– fileupload_url (for wordpress 2.x) or upload_path (for WordPress 3.x) (if you’re going to upload images or contents in your local site)
For example, assuming that you have wordpress in C:\xampp\htdocs\wplocal, in wp_options, update:
siteurl
http://www.yoursite.com –> http://localhost/wplocal
home
http://www.yoursite.com –> http://localhost/wplocal
fileupload_url (for wordpress 2.x) or upload_path (for WordPress 3.x)
http://www.yoursite.com/wp-content/images –> http://localhost/wplocal/wp-content/images
8. That’s it. Goto http://localhost/wplocal and enjoy your local wordpress site with all the contents. The next time you make your backups, exclude wp_options since you don’t want to change the options again.
9. If you really like the theme you use in your live site, download it and put it into C:\xampp\htdocs\wplocal\wp-content\themes. Select to use the theme. Now, you have a total 100% duplicate of the content + presentation.
10. Try it out yourself. You can even run wordpress locally as your personal diary.
lawn dresses says
can i use worpdress on wamp and attach there database to my hosting account.?
David says
Yes, you can use wordpress with WAMP.
Yes, you can “export” your local wordpress database and “import” it into your hosting account.
Brad Dalton says
siteurl
– home
– fileupload_url
Where do i find the file that contains these details so i can edit them?
David says
Brad, they are both in the wp_options table.
fileupload_url can only be found in wordpress 2.x. I highly doubt that you’re still using such an old version.
You’re probably using WordPress 3.x already, so look for upload_path instead.
This is mentioned in the article as well 🙂
Patrick "Nuwud" Wood says
This was very helpful.
Thanks!