For Developers Looking for a Robust Solution
Method 2: The Manual Guide to WordPress Staging (cPanel)
Moreover, if you're a power user and want to play with codes, then doing it manually will surely benefit you. In this method, you create a staging site using a subdomain in your hosting cPanel. This method can also be called as WordPress Hosting Staging. Hence, we are going step by step to ensure that you get the most credible and easy experience in setting up a WordPress Staging Environment.
Step#1: Creating a Subdomain using cPanel
The first step is to log in to your hosting cPanel. After that, scroll down into the "DOMAINS" section and click on "Subdomains".
Moreover, create a subdomain with the name you want and click "Create".
Step#2: Creating an FTP account to control your staging site
Additionally, you will have to create an FTP account by clicking on "FTP Accounts" in the cPanel.
Enter your WordPress staging site's account details and make sure to enter "public_html/staging" as your root directory.
Step #3: Pushing your WordPress file to the staging site
Hence, using that FTP file that you just created, it's time to push the WordPress content towards the staging site. First of all, you have to download the latest version of WordPress and upload it on the FTP Moreover, you will have to upload all the contents of your current WordPress site to the staging site using the File Manager as well.
Step #4: Importing and Exporting Files
You can use plugins such as MigrateDB to push all the content to your WordPress staging site. Therefore, the tool of our liking is the MigrateDB plugin. Download and install the plugin. And you access the tool by going into Tools > Migrate DB.
Here, you will have to give the exact directory of your subdomain. Additionally, you will have to access the cPanel again to create a database using MySQL. Click on the MySQL database and add a new database named "Staging" and an account named "Staging" too. You can change the name of the ones you want.
Moreover, you also have to go to "PHPMyAdmin", import the database that you're just created and click "GO"
Step #5: Successful WordPress Staging Website - Pointing to the Database
This step is rather simple. All you need to do is to edit the wp-config.php to change it to the new username and database details. Moreover, you also have to change the prefix of the database and match it with your live site.
This way, the staging site will be successfully pointing towards the database. After changing the details, you can just upload the config file back using FTP or file manager.
Final Step: Discouraging Search Engine from Indexing this Site
The final and last step is to go to settings>reading, and select discourages search engines from indexing this site. This will restrict search engines like google to show the results.