How to setup your WordPress development environment

“Never work on a live site!” Advice to live by. It is important to setup a WordPress development environment to maintain and ensure a high quality web page.

What is a development environment?

A WordPress development environment allows you to test your riskier projects before they move to your live site.

You always want to try out major features in a this kind of environment before deploying them.

  • It allows you to test your changes on a  subdomain. Then look for problems, without no risk of your live website seeing issues.
  • You can configure your site environment to your liking.  Change themes or plugins you installed show compatibility errors, among others.

Once you’ve tested your site, you can then upload it making everybody happy.

Before you begin create a backup of your site

How to Setup your WordPress Development Environment

To setup a Development environment we need to do a few things they are easy so don’t worry. First, a subdomain needs to be created that is a spinoff of your main domain.

Creating a Subdomain

A subdomain is just a sub folder on your WordPress site that most user will never see. It is a new URL followed by your main URL. For example Deveopment.YourBlogName.com. The subdomain will allow you to view changes to your website, without affecting your main database, files, or uploads.

Most hosting company’s have a cPanel set up and as such This is the way I will be doing it:

  • Log in to your hosting account
  • Login to your cPanel
  • Find the Domains box
  • Click on Subdomains

 

  • Click on Subdomain name.
  • Add your desired Subdomain name
  • Click the Create button to set up your subdomain

Your subdomain has been created!

Setting up the easy way

If you have Softaculous install the easyst way to set up your dev page is create a clone of your main page.

  • From Cpanel click find Softaculous APPS installer
  • Click WordPress
  • You should be taken to a new page, down at the bottom you should see your current page and to the right you should see options. The first Icon is clone
  • Choose the domain path you setup above
  • Set the database name in “Database Name” You want to ensure the name is descriptive and unique so you can easily remember it. TIP: Do not use spaces or special characters. I will be using devDB
  • Click clone instillation.

That is it you are all done. You now have a cloned page!

Now that you are done You can get some inspiration for some future themes from The Theme Forest as there is a huge selection. I use Nakhra theme but you can choose one starting as low as $13 like this one.

Setting up the manual

Creating a Database

  • In cPanel, find the “Databases”box and click on “MySQL® Databases

 

Create a name for the database in “Create New Database” box. You want to ensure the name is descriptive and unique so you can easily remember it.  TIP: Do not use spaces or special characters. I will be using devDB

  • Click the Create Database
  • It is important to make note of your database name as we will be using it often.

Your database is now created and ready for use for WordPress testing. How do you access it? Glad you asked.

Database Users

With the database created we need to create a database user and set up the permissions. If you already have a user created then skip to “Adding a User to the Database”. Otherwise let’s create a new user:

Creating a new Database User

  • In the MySQL Databases screen scroll down the page until you see MySQL Users.
  • In the section labeled Add New User, enter a username. It is very important that your username and password is unique and separate from the one you logged in with.
  • Enter a strong password or click the Password Generator button, I highly recommend the Password Generator.
  • Click the Create User
  • Make a note of the username and password.

Check, you have now created a new user. Now we will add them to the database.

Adding a User to the Database.

With your User created we need to add them to the Database so work can be performed.

  • Scroll down the MySQL Databasesscreen until you see Add user to Database.
  • Select the user in the first drop down and select your database in the second drop down.
  • Click the Add button.
  • You should be redirected to the Manage User Privileges screen.
  • Check the All Privilegesbox or select every check box manually.
  • Click the Make Changes
  • Click Go back to return to the MySQL Databases screen.

The database is set up. If you would like a brake now is a good time. You can get some inspiration for some future themes from The Theme Forest as there is a huge selection. I use Nakhra theme but you can choose one starting as low as $13 like this one.

Copying Data from Live Site to Staging Environment

The real reason you are here is to set up your staging site. You want your staging site to run everything your live site has including all themes plugins, images and other attachments.

If you have not already it would be a good idea to create a backup of your site.

  • Navigate back to your home page of cPanel and open your File Manager and find the themesplugins and uploads folders inside the wp-content folder in your NEW staging site.
  • Delete these 3 folders in the new staging folder.
  • Now, go to the wp-content folder in your live site. [/home/USER/public_html/wp-content] Select the folder and click copy and select the folders for your staging site.

Next you need to copy the database tables.

Copying Database tables

The best way of doing this is by copying the database tables. You’ll need to use phpMyAdmin to do this, which you access via cPanel.

  • From the home page scroll down to Databases and open phpMyAdmin for your LIVE site and find the database.
  • Click on the Export tab.
  • Click Go
  • A SQL file with your database will be downloaded.
  • To import the database tables some edits to the SQL file will need to be done
  • Open the SQL file in and replace all instances of the old domain name new staging domain name. In other words, replace all instances of http://yourdomain.comwith http://staging.yourdomain.com(use the name you wrote down).
  • Save your SQL file.
  • Click on the staging database and, you need to delete (drop) the tables that WordPress has created.
  • Select all of the database tables.
  • Click on the With selected: drop-down box, select Drop and click Yes.
  • Still in phpMyAdmin, select the Import tab and click the Choose file button.
  • Select the SQL file that you’ve edited (on your local machine) and click Choose or OK.
  • Click Go and your database tables will be imported.

You’re done! Now check your staging site. It should look exactly like your live site.

Wrapping It Up

From now on, every time you need to update WordPress, or a theme or plugin, you can do it on your staging site first, test that, and then make the updates on your live site. You can do it in a way that is safe and avoids creating any errors.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.