Do you need assistance in creating a WordPress staging site using cPanel? A staging site, also known as a test site or development site, is an exact replica of your live site. It allows you to make changes privately without affecting your live site. This is an incredibly valuable tool if you are:
- Testing plugins for compatibility
- Ensuring that your WordPress theme is compatible with new updates
- Implementing major features and content on top of your current site
- Fixing glitches, bugs, or security vulnerabilities
- Building a new site, among many other reasons.
If your WordPress site generates income or experiences high traffic, learning how to create a staging site with cPanel will help reduce disruptions. For instance, if something goes wrong on the staging site, you can easily revert the change, delete everything, and quickly duplicate your live site again.
In this step-by-step tutorial, we will guide you on how to manually create a WordPress staging site using cPanel, essentially for free. While plugins and services are available for your convenience, they may come with a fee. So, if you are on a budget or simply curious, let’s get started!
Step 1: Create a Subdomain
Login to your cPanel and create a subdomain. The location of this option may vary depending on your cPanel setup, but you can typically find it under Domain > Subdomain. Take note of where the staging folder is located in your directory. For example, in this tutorial, the staging folder is located at:
alexthedigitalproducer.com/public-html/staging (remember, yours will be different).
Step 2: Duplicate the Live WordPress Site to the Staging Site
From cPanel Home, access File Manager and navigate to your ‘public-html’ folder. Copy everything in this folder and paste it into the staging folder. However, if the ‘staging folder’ is also inside ‘public-html’, avoid duplicating that folder.
After copying the files, go into the staging folder and find a file named ‘wp-config.php’. Right-click on the file and select View. Approximately 30 lines down, make a note of your database name and database username. These will be important later in the tutorial.
Step 3: Duplicate the Live WordPress Site Database
WordPress not only consists of pages to display your site, but it also includes a database that manages and pushes important data, ensuring your site looks and functions correctly.
Exit File Manager and go back to cPanel Home. From there, navigate to phpMyAdmin.
- On the left navigation bar, click on your live site’s database name.
- On the right panel, click on Operations.
- In the ‘Copy Database to’ subpanel, assign a new name to your staging database. For instance, in this tutorial, we’ll name the staging database ‘atdp_staging’.
- Click Go to start the duplication process. It’s crucial to wait and not interrupt this process to avoid creating a corrupted database.
Step 4: Configure the Staging Database
- In phpMyAdmin, navigate to your newly duplicated staging database.
- Go to the ‘options’ table.
Note: Each WordPress database installation usually has tables with prefixes. For example, ‘wp_options’. The prefix may vary, but most of the time, you’ll find a ‘[prefix name]_options’ table.
- Locate the ‘siteurl’ entry and click Edit. Change the URL to the staging URL and click Go. If you can’t find ‘siteurl’ in the table, use the ‘Filter rows (*)’ option to search for it.
- Repeat the same process for ‘home’. Change the URL to the staging URL and click Go.
- Exit phpMyAdmin and return to cPanel Home.
Step 5: Assign the Staging Database to the Database Username
Recall that in Step 2, you were asked to note down the database username. At cPanel Home, go to MySQL Databases and click on Add User to Database.
In the ‘User’ panel, refer to your notes from the staging ‘wp-config.php’ file for the database username. In the ‘Database’ panel, add the name of the duplicated staging database from phpMyAdmin. Finally, click Add.
You will be directed to another page to provide permissions for the user (e.g., webmaster/administrator). Tick ‘All Privileges‘ and click Make Changes. Then, exit the MySQL Databases section and return to cPanel Home.
Step 6: Configure the ‘staging/wp-config.php’ File
Open File Manager and navigate to the staging folder. Right-click on the ‘wp-config.php’ file and select Edit.
You will see a warning prompt. Create a backup of wp-config.php (just in case) and click Edit again. Approximately 30 lines down, change the database name to the one you created in phpMyAdmin. Click Save Changes and then Close.
Exit File Manager and log out of cPanel.
Step 7: Finalize the Staging Site
Congratulations, you’re almost there! Well done for coming this far.
Open your web browser and enter the staging site URL followed by
/wp-admin to access the backend. For example,
Tip: The username and password are the same as the ones on your live site.
In the Common Settings section, select Post Name and click Save Changes. This step is important because the permalinks still refer to the live site. Updating this ensures that the permalinks reference the staging site.
That’s the end of the tutorial! You now know how to create a WordPress staging site with cPanel, allowing you to safely make edits on the staging site without affecting your live site. But wait! What happens when you finish editing the staging site and want to migrate everything to the live site? Stay tuned for our upcoming tutorial, which will be released next week. Watch this space!
If you found this tutorial useful, please leave a comment below and share this blog. Let us know if you have any topics you would like us to cover in the future.