Skip to content

10 steps to creating a WordPress development site

February 17, 2012

When I first turned my back on my comfortable corporate job using an enterprise-level CMS (Fatwire) and dove headlong into using WordPress as a CMS for a small business the first thing I wanted to do was create a development area.  A test site.  A staging area.  Call it what you will it all means the same thing, somewhere that you can break the site on a regular basis without losing your job.

I thought this would be fairly easy, a fundamental thing that everyone wants to do.  As it turns out a lot of people are happy to edit their site live (MADNESS). Those people who did have a test site suggested a myriad of ways of doing it and I soon found myself confused.

So, here is how I did it in ten simple steps, it’s worked for 3 sites now and may help you:

Note: This assumes some knowledge of FTP servers, website databases and WordPress CMS, but if you aren’t sure about something just post a comment and I’ll help out where I can.


1. Create a ‘test’ folder at your site root

You can call this folder whatever you want, to make life easy name it whatever you want your test site URL to be (e.g. http://www.domain.com/test or http://www.domain.com/staging). It’s easiest to do this via your FTP client, my personal choice is Filezillla.


2. Duplicate your current site database

This assumes that you want your test site to be an exact copy of your current live site before you begin editing away.  All of your site settings, pages and posts will be the same (except for the ones we will change later).

First, export your live database via MySQL using a database management tool (I use phpMyAdmin) and save the .sql file locally.  Next, create a new database and database user via your web host control panel, name it something distinct from your live database to avoid confusion (preferably include ‘test’ in the name somewhere).  Finally, login to your newly created database and import your saved .sql file.

 


3. Amend the test database to point towards your test domain

Access your replica database via your database management tool and navigate to the table ‘wp_options’.  There are two fields in here that you need to edit, usually they are at row 1 and row 37.


4. Copy your WordPress site files to the test folder

Using your FTP client copy all of your live site WordPress files to your local directory (this will serve as a backup of your site). Include wp-admin, wp-content, wp-includes and all other files at the root of your WordPress folder.

Once complete, copy the same files from your local drive to the test folder we created in step 1.


5. Amend wp-config.php to point at your new site and database

In the local back-up of your site open ‘wp-config.php’ in your HTML editor and amend the following lines to point to your new domain and database:

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘yourtestdb’);

/** MySQL database username */
define(‘DB_USER’, ‘yourtestuser’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘yourtestpassword’);

Then add in the following under the WordPress Debug section to complete the redirect of your site to the sub-folder:

define(‘WP_SITEURL’, ‘http://www.yourdomain.com/test’);
define(‘WP_HOME’, ‘http://www.yourdomain.com/test’);

Save this file (do not overwrite the file in your backup if you want to be able to revert to it) and copy to the test folder via FTP.


6. Amend the .htaccess file in your test folder

This file should be in the root of your wordpress installation, if you don’t have one you’ll need to create it. In it’s simplest form your file should look something like this once you have added ‘/test’ to the end of the domain:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /http://www.yourdomain.com/test/
RewriteRule . http://www.yourdomain.com/test/ [L]
</IfModule>
# END WordPress

Save this file (again, don’t overwrite the one in your backup) and copy it over to the root of your test folder via http://FTP.  If you go to http://www.yourdomain.com/test/wp-admin you should now be able to access the login screen for the replica of your site, the username and password will be the same as they are for your live site.


7. Amend robots.txt to stop Google finding your test site

This file should be in the root of your WordPress directory, if you don’t have one create it and add the following:

User-agent: *
Disallow: /test/


8. Make sure Google can’t find your site via the WordPress privacy settings

Login to the dashboard of your site and go to Settings > Privacy, change the option selected to ‘I would like to block search engines, but allow normal visitors’ and save.


9. Install the ‘WP Maintenance’ plugin to hide your test site from the world

This is an optional step but if you don’t want the general public to stumble across your test site this plugin will present a holding page when activated to users who are not logged into the CMS.


10. Test your replica site

Before tearing your site apart make a few simple changes to various pages and check that they only occur on the test domain. Just to be sure!


I’m sure there are probably better ways of doing this, but this method works for me!

Advertisements
2 Comments leave one →
  1. February 23, 2012 5:16 pm

    This is the most easy to follow method I have seen so far. Thanks!

    • topherknowles permalink*
      February 23, 2012 5:31 pm

      No problem Brian, hope it helps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s