Oct 312012
 

Last Updated: November 12, 2013

Test Your WordPress Site Locally tutorial will show you how to run your live website locally using Xampp. I will be using BackWPup backup to install and setup my live website locally for testing using Xampp and Windows 7.

Important Information: These steps can be applied to just about any backup plugin as long as the backup is a full backup which includes all the files, folders and the database.

Latest News: I have added an extra step 16  thanks to Eric. I left out adding the new user name and database to the wp-config.php file. I have also added more information so that you don’t get confused about certain steps. This tutorial is now a three part tutorial. You must complete all three parts or else you will run into issues.  

This Is A Three Parts Tutorial:

  1. Install WordPress Locally Using Xampp.
  2. Install WordPress Locally Page Two.
  3. Test Your WordPress Site Locally.

1 ) Start Xampp Apache and MySQL. See image below.

import-backwpup-backup-locally

2 ) Locate your BackWPup backup folder locally to copy over to the local server “Xampp”. Remember to unzip the folder, to copy the files. See image below.

import-backwpup-backup-locally-part2

3 ) The files are being copied over to the Xampp server “local”. See image below.

import-backwpup-backup-locally-part3

 4 ) Start phpMyAdmin to import the database from BackWPup folder we just copied over to the Xampp local server. See image below.

test-backwpup-backup-locally-part4-xampp

5 ) We need to drop all the tables from the local WordPress install before we can import the database. Click on Check All to select all tables. See image below.

drop-table-xampp-backwpup-locally

6 ) Click on Drop to drop all tables selected. See image below.

drop-table-xampp-backwpup-locally-part2

7 ) A window will open up asking you “Do you really want to: “, click on Yes. See image below.

drop-table-xampp-backwpup-accept-changes

8 ) Click on Import and then click on Browse to search for the database to import. Notice that I am allowed to import 128M file size into the database (Please review the first tutorial Install WordPress Locally Using Xampp Step 3 to learn more about making changes to Apache). See image below.

import-backwpup-locally-part7

 9 ) This is the database file I am going to import, yours will look something similar. Remember that BackWPup always adds the database file to the root of your WordPress website when you create a backup. See image below.

locate-database-backwpup-locally-part8

10 ) You can see the file path entered here. Click on Go to import the database. See image below.

import-database-backwpup-locally-part9

11 ) If everything goes well, you should see a message like this. Notice the prefix ‘k4oqobp_‘. I need to add this to the wp-admin.php file later on. You will have a different prefix to add to your wp-admin.php file. See image below.

 database-imported-backwpup-locally-successfully

12 ) There are some changes that need to modified before you try to log in or run your website locally. In my installation I selected the following table k40q0bp_options for editing, you will have to do the same. See image below.

make-changes-database-locally-backwpup

13 ) I am going to type my new path, http://localhost/wordpress/. (Please note: Your home path will be different, please visit Part 1 Install WordPress Locally Using Xampp Step 4 to learn more). See image below.

Please Note: http://localhost is the root of Xampp server. 

 type-local-path-database-backwpup-xampp

14 ) I am also going to change the home path (Please note: Your home path will be different, please visit Part 1 Install WordPress Locally Using Xampp Step 4 to learn more). Click on number 2 to view more options on this table. See image below.

add-home-path-locally-database-backwpup-xampp

15 ) Make the same changes to this field as you did previously (Please note: Your home path will be different, please visit Part 1 Install WordPress Locally Using Xampp Step 4 to learn more) Change the path to the following: http://localhost/wordpress/. See image below.

add-home-path-locally-database-backwpup-xampp-part2

16 ) I am going to add the new database name, username and password to the wp-config.php file (Remember this was completed in Part 1 Install WordPress Locally Using Xampp Step 6 through to Step 12). See image below.

import-backwpup-locally-edit-wpconfig

17 ) The table prefix needs to be changed. Open the following file wp-config.php, located on the root of your installation. See image below.

change-table-prefix-local-database-xampp-backwpup

18 ) Locate this line $table_prefix = 'wp_'; on your file and change the default WordPress prefix ‘wp_‘ to the following prefix ‘k4oqobp_(Remember that your prefix will be different). See image below.

edit-wp-admin-php-wordpress-xampp-locally

19 ) I have now typed the new prefix ‘k4oqobp_‘ (Your prefix will be different). Make sure that you save your changes. See image below.

 edit-wp-admin-php-wordpress-xampp-locally-part2

20 ) You will see your path when you go to log into the admin panel on the browser. This is the reason why it is important to make the previous changes or else it defaults back to your online server path which you don’t want.

Log in with your normal username and password. This is the username and password that you use online. See image below.

import-backwpup-locally-xampp-running

21 ) If I type http://localhost/wordpress/ on the browser, I will see my website running locally (Please note: Your home path will be different, please visit Part 1 Install WordPress Locally Using Xampp Step 4 to learn more). See image below.

import-backwpup-locally-completed

I have completed the task. I now have my live website running locally using Xampp in Windows 7. Hopefully you have too and can see your website locally as well.

Important: There will be other settings, plugins and links that might need attention. But be aware that if you run the website locally for testing and then decide to upload back to the server, you will have to revert back the changes you made to what they are on your live server. So make a note of what ever changes you make.

If you have any question please let me know.

I hope this tutorial helps you.

Enjoy

LinkedIn
Manuel Ballesta RuizManuel Ballesta Ruiz has written 237 posts. He can be followed on Twitter.

  17 Responses to “Test Your WordPress Site Locally”

  1. Thank you soooo much for posting this tutorial! I was struggling for so long to set up my website on a local test environment and I finally succeeded after following your tutorial! I did it on my WAMP server and works in a very similar way. Thank you so much!!!

  2. Just wanted to say thanks for the tutorial on this page and the tutorial on how to backup and restore using BackWPup. Much appreciated. One additional thing I had to overcome was that the database I restored to had a different name, username and password. I had to update these in the wp-config.php files as well.

    • Hello Scott, thank you for your comment. Thank you for pointing out your action in relations to the different name and password in the database. This is something that some users often overlook and that is why at the end of the tutorial I added an extra comment, there might be other settings that might need checking and possible changed. I am happy that my tutorials were able to help you.

      Kind regards

  3. Your tutorials are clear and easy to follow, definitely 5 stars, … until I reached the end ;)

    After following the tutorial for backing up (http://mbrsolution.com/tutorial/backup-restore-wordpress-using-backwpup-plugin.php) I then followed these instructions for testing locally. I did not have any problems until I got to step 19, where, I ran into a couple of issues.

    The first was HTTP 500 error

    So, I set define(‘WP_DEBUG’, true) in wp-config.
    Then I could see an error message: Warning: mysql_connect(): Access denied for user ‘lightnm0_wor1′@’localhost’ (using password: YES)

    That was weird because I don’t remember creating that user name.
    So (after researching a bit) I queried the DB for the mysql user name which turned out to be “root” w/o password. Then I changed wp-config to reflect this.

    This resolved the first issue, but then I found two things
    1) The site content was displayed, but it was unformatted, as if missing the CSS file
    2) unable to log in – apache seems to be in an infinite loop of port IDs.

    I am hoping, there is some simple fix – it seems so close, yet so far away.
    Thanks,
    -Eric

    • Hello Eric thank your for your comment. In regards to your two questions?

      I found two things
      1) The site content was displayed, but it was unformatted, as if missing the CSS file
      2) unable to log in – apache seems to be in an infinite loop of port IDs.

      Can you please check to make sure that your live site is running without a problems? Then create a new backup and download it locally and follow my instructions again but with the new backup.

      Having no css or missing a css file means that your original backup might have an issue which in the future could cause problems. Let me know how you go.

      Also let me point out that sometimes and not related to your issue, if you run different PHP and or MySQL versions can also cause problems.

      Kind regards

  4. Good news!

    The problem turned out to be the result of setting the siteurl incorrectly in the DB. I re-installed my previous local site. When it was working correctly, I started checking everything to see if I could notice any difference from the backup. Then I observed this the siteurl set to “localhost” only.

    The WP documentation on setting this parameter is less than helpful:
    ‘The “Home” setting is the address you want people to type in their browser to reach your WordPress blog.
    The “Site URL” setting is the address where your WordPress core files reside.’

    I am still not clear on how exactly to set these, but my guess is that siteurl can be set to localhost because the XAMPP config file is pointing to folder where wp is stored.

    The problem (incorrectly set siteurl) is consistent with the symptoms: the content, pulled from the DB, was all intact, but the none of the other files could be found.

    Anyway, the good news is that I am back on track and it looks like the BackWPup backup has been verified.

  5. I have two suggestions for improvement:

    1) Instruction #15 caused me to set up incorrectly. I am not sure why it worked for you.
    2) I think you need to include a step to verify that you have the correct username and password for mysql

    Finding my way around these two issues cost me a week!

    But to be fair, I never would have gotten to square-one without this tutorial.
    So: Thanks! … really appreciate the help.

    -Eric

    • Hello Eric I am happy you manage to solve your issue. Sorry for not adding the extra step which caused you to spend 1 week sorting your issue. I have now added a new step 16 that includes adding a new database and user name to wp-config.php file.

      Kind regards

  6. This is very helpful tutorial, but some steps are incorrect on my windows 7 version of XAMPP. So I want to make four suggestions.

    First: In step 8, the limit was set to 2M by default so I had to increase the number. It took me a long time to find out where the parameter was set, so you might save other people some time by telling them that the “upload_max_filesize” parameter in the xampp\php\php.ini file is where to set the new value.

  7. Second: In steps 13 and 15, I found it was necessary to set both siteurl and home without the trailing “wordpress” directory. I think this setting depends on how the DocumentRoot and Directory parameters are set in apache.

  8. Third: In step 16, the setting of DB_USER and DB_PASSWORD are determined by the settings in the “user” table of the “mysql” database. It would be helpful for others to know that.

    Lastly, (and this not very important) the instructions randomly use “I” and “you” interchangeably. This is a little confusing and would be much easier to read if you stick with either first person (I) or second person (you).

    Thanks again. This tutorial is very helpful and backWPup should provide a link to here! (after you make the corrections I suggested ;)

    • Hello Eric and thank you for your reviews and suggestions. I have made many modifications to better explain the process. Let me know if you feel I left out something.

      Once again thank you for your review.

      Kind regards

  9. With all due respect, your change did not sufficiently address the problem. As far as I can tell, you added this warning “(Remember your path will be different)”. What you need to say is “Please note: your path will be different – and in some cases it may consist of ‘localhost’ only).

    The problem with your reminder is that the casual ready will think you are only reminding them that folder portion of the path will be different, when, in fact, there might be no folder at all.

    But a warning is not the most helpful approach here. It would be better to provide instructions on how to determine exactly which path to use. (my theory is that it depends on how apache is set up, as I mentioned above).

    It is important to explain this carefully because it is very difficult to debug if set wrong.

    • Hello Eric thank you for pointing that out, I see your point. I have edited my comment to help those who don’t know anything about Apache and about creating directories to install WordPress if needed.

      Thank you

  10. Another suggestion is in step 8 you can mention: “(Please review first tutorial if this is not set to 128M)”
    If they missed this step or skipped the first tutorial, they will know where to go for the answer.

 Leave a Reply

(required)

(required)

5 × 3 =

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>