Be super-careful when you are following these instructions and be very sure not to edit the web server or database for your actual website! Always be sure that you have backed up your database and web server before doing this, just in case.
We’re going a little out of order here, but this topic has come up several times already and is so important that I thought we should cover it immediately.
So how do you set up a test site for your WordPress blog? First, purchase a separate domain name (anything works) and set it up for hosting. Then, take the following steps to copy your production site (the techie term for your user-visited website) to your test site.
Let’s say your production site is www.mycookingsite.com/blog and your test site is www.mytestsite.com/blog.
- FTP the following files and folders from www.mycookingsite.com/blog/ to your computer or hard drive:
- On your computer or hard drive, delete the plugin folder for wp-stats if you have it enabled. This is to insure that you do not confuse WordPress’s dashboard when you create your test site.
- FTP all of the individual files that are at the same level as the wp-admin, wp-content, and wp-includes folder to your computer or hard drive.
- FTP all of the files from your computer or hard drive into www.mytestsite.com/blog/.
You’ve now made a copy of everything on your web server except your images (no need to have these on your test site).
- You have already downloaded the nifty WordPress Database Backup plugin. If you have yesterday’s backup handy, great, otherwise go to Tools → Backup and run a backup of your entire database.
- Create a new SQL database through your web hosting company.
- Through your web hosting company, there should be a service called phpMyAdmin. Log into phpMyAdmin using the username and password for your database.
- Select your newly-created database in phpMyAdmin and click on the “Import” tab.
- Browse for your backup file, be sure that the SQL button is checked, and click Go.
- In phpMyAdmin, click on your test database, and the table wp_options (or wp_xxxxxx_options). BE SURE YOU ARE IN YOUR TEST DATABASE.
- Find the option name “siteurl”.
- Click the pencil on the siteurl line to edit the information.
- Change the siteurl to your test site.
- In FTP, navigate to the root of your TEST wordpress installation. In our example this would be www.mytestsite.com/blog.
- Open the file called wp-config.php
- Change the values for DB_NAME, DB_USER, and DB_PASSWORD to your test database information.
- Visit www.mytestsite.com/blog/wp-admin and log into your test site. You will log in with the same username and password as your production site.
- Verify that your test site is visible at www.mytestsite.com/blog.
Voila! A perfect copy of your blog. Use your test site to edit your theme, install new plugins to play with, develop new functionality, test upgrades of WordPress or plugins, etc before applying the changes in production.
PS – If you aren’t on WordPress, but instead have an HTML website, you should still have a test site. Simply FTP the files from your web server to your computer, and then FTP back up to your new domain.
PPS – Your web hosting provider should also allow you to easily password-protect your test site’s domain.
Edited To Add: PPPPS – See comments below for some reasons why you need a test site – this can include changes to your WP theme, or testing out plugins and new functionality, and creating new page templates – and also a shortcut method that doesn’t involve a whole backup of your production site.