February 4, 2019
February 4, 2019
WordPress is limited to preview changes in posts and pages. What if you want to preview a different theme with additional changes or completely re-make your website? Doing all this on a live WordPress site may be inconvenient for your visitors. This tutorial shows you how to create a staging environment for your WordPress site and develop it without affecting the live version.
Before you begin this guide you’ll need the following:
Create a subdomain for your staging environment. In this example, we will be using staging.example.com subdomain (example.com being our main WordPress domain). If you are not sure how to create subdomains, refer to this tutorial for more details on how to create a subdomain
Copy all the files from the existing WordPress installation to a newly created subdomain. In this case files will be moved from public_html/ to public_html/staging/. Refer to a tutorial on managing files via File Manager for more information.
Duplicate the existing WordPress database. In this example, we will copy database techno75_wp792 to techno75_staging. There are quite a few ways to duplicate WordPress database:
On a newly created database there will be no privileged users. Don’t forget to add the same original user from your existing WordPress installation:
Refer to tutorial on databases and users for how to
add a privileged user to a database.
Open up wp-config.php file located in your newly created subdomain (in this example it’s public_html/staging/wp-config.php) and add the following lines:
IMPORTANT: Change subdomain to your newly created staging subdomain and domain to your original WordPress domain.
The staging environment is now ready for use. To apply all the changes you have made to your staging copy of WordPress you need to copy the staging database back to the original one and do the same with all the files from the staging subdomain.
You have learned how to quickly create a staging environment for a WordPress site. You can also password protect the staging copy if you don’t want others to access it.