This guide offers a step-by-step guide to create a dedicated Subdomain for WordPress Staging. We will briefly explore the importance of having a dedicated subdomain name for WordPress staging purposes.
Why Do I Need a Subdomain for Staging?
When configuring your staging version, the most important aspect is where, within the parameters of your account's filesystem, to create and run your staging version.
Keep in mind, that while the staging site is not your actual production WordPress site, it is still a WordPress site. You will want to use similar practices as if you were installing another production WordPress site as an Addon domain within the hosting account.
We strongly discourage anyone from installing the Staging site to a subdirectory of the production site, as this could have unintended consequences. By installing the staging environment as a subdirectory of your Production WordPress site, the staging site files will be subjected to any web server directives applied by the Staging installation as well as also having the production installation's web directives applied. While this may not occur initially, any future changes made to either installation increases the opportunity for conflicting directives being applied and they can be hard to troubleshoot and thus, very frustrating, for the typical WordPress admin.
We want to avoid any risky code-collisions between production site and staging site. The reason for the staging site, is, after-all, to eliminate potential issues created by pushing untested changes directly to live production site.
For these reasons, we recommend going for a subdomain, and configuring the subdomain to reside below the web root of your filesystem. This will ensure no "cross-contamination" will occur between your production and staging sites' files.
Steps to Create a Dedicated Subdomain for WordPress Staging
To create a dedicated subdomain for WordPress staging, follow these steps:
- Login to your cPanel account
- Navigate to and click the "Subdomains" icon within the "Domains" section of cPanel
- Now add a Subdomain of your Production WordPress's domain name.
(In this example, our production site uses wp.raddemo.host, so we will configure a subdomain, staging.wp.raddemo.host to meet this recommendation) - Ensure the document root is below /home/{youruser}/public_html directory, where {youruser} is your cPanel account username.
(in this example, our document root is configured to /home/username/staging.wp.raddemo.host) - Click "Create" to create the subdomain in accordance with your configuration in the previous steps.
- Once you receive confirmation of successful subdomain creation, you are ready to setup your staging site to use it
You now know how to create a dedicated Subdomain for WordPress staging, as well as some reasons why this is a good step to take to avoid potential disruptive issues in the future.