Create a Dev or Staging Environment in cPanel

Create a Dev or Staging Environment in cPanel

The Dev and staging environment is mainly created for developers. This is for testing a website without disturbing the original site. When the dev or stage environment is created it will replicate website files and database. 

Step 1: Create Subdomain in cPanel

  1. Login to cPanel
  2. Search for the subdomain. 
  1. Enter Subdomain, Document root after that click on create button, New subdomain will be created.
  1. A successful message will be displayed

Step 2: Make a copy of the Database

You have to access phpMyAdmin to create, and copy the database 

  1. Search for phpMyAdmin in cPanel. I will be under the Database section
  1. You have to know your database after that click on operations
  1. Find the section “Copy database to”, this is where you’ll name the database your dev or staging environment is going to use. Enter the name and click the Go button on the far right.
  1. A new copy of the database will be created 
  2. For those who are using WordPress, they have to update two values in the wp_option table  Your table prefix may be different. in this example it’s wpjf_
  1. After loading the wp_option table. You will see a row for siteurl and home. Update these two values with your new dev or staging subdomain. Update these two values with your new dev or staging subdomain.

Step 3: Create a Database user.

After Creating the database create a database user and assign that database user full privileges to the newly created database

  1. Search for MySQL® Databases in cPanel
  1. The next page will open, scroll down below. Under the MySQL Users section, there is Add new user enter the database Username, and Password and then click on create a user.
  1. Click the go-back button. under Add User To Database section select the newly created user and newly created database. (Created in Step 2). Click on Add Button
  1. On the next page tick on ALL PRIVILEGES. Then click on Make changes.

Step 4 : Copy website files 

  1. Go to file manager in cPanel.
  1. Navigate to Public_html and select all files and compress them. A pop-up will open and select for zip type. It will create a zip file under your public_folder
  1. Reload the page you will see a zip file
  1. Transfer the .zip file to the subdomain you just created in the first step. The directory for your new subdomain may be either inside or outside of your public_html. Our website, dev.cgi-sql.com, is shown in the example below and is located outside of the public_html.
  1. Now go to your dev or staging environment’s document root and you should see the .zip file. select that file and click on the Extract button. A popup will appear to click on the Extract files button.
  1. All files are extracted under your root folder

Note: This is for WordPress users only.

  1. Select the wp_config file and right click on it and click on the edit option.
  1. Update the database name, database user and password which is newly created.

Now you can browse your subdomain in the browser.