How to create a staging copy of your wordpress blog

How to create a staging (test) copy of your wordpress blog. Tips, Tricks and Best Practices on how to create a wordpress blog staging copy.

 

The contents of the article

  • What is a staging environment?
  • How to create a Staging environment
  • Create a second level domain
  • Install https on second level domain
  • Create staging copy with CPanel
  • Create staging copy manually
  • Hide staging copy from search engines
  • Conclusions

Would you like to test a new plugin but can’t do it directly on your blog? Would you like to change the look of your site with a new template and test its features? Would you like to develop and see how your website reacts?

If you are asking yourself these questions then you need a staging copy of your wordpress blog that allows you to test , verify and customize before bringing the changes to your live blog.

In this article I will explain what a staging environment is , why it is important to have a staging environment for a wordpress blog and above all how to create it step by step using various techniques (manual, with cPanel and via plugins)

What is a staging environment?

A staging environment or even called pre-production environment is a mirror copy of your live blog (website), which you can use to do tests , functional checks , patch installations and new templates .

For example, I use it a lot to test the graphics component , just think of when gutenberg came out or the many graphic aspect migrations that I have at all to my blog over time.

 

Without a staging environment it would have been impossible to test the new features of the various themes , new plugins and changes to the text editor .

If you want to be a blogger you must have a #pensandoit #etrusco staging environmentCLICK TO TWEET

Come and see how to create a staging environment.

How to create a Staging environment

As mentioned, a staging environment is a mirror copy of your wordpress blog , so to create a staging environment you will need to create a replica of your blog.

The more complex systems, especially when it comes to enterprise systems , have automatisms that allow you to keep production and test environments ” synchronized “.

We will settle for a specular environment , to be used for testing, verification and installation without creating this automatic synchronism which, in my opinion, does not make much sense for a blog.

First you will need to prepare the ” container ” of the test environment, which will be a second level domain (eg staging.yoursite.it ), configure it by installing patch and secure protocol and then ” copy ” your blog into the new container, transferring it file and database .

Finally you will have to obscure the new environment from the search engines and above all make it inaccessible to anyone who does not have an enabled user by activating the ” coming soon ” mode, in this way only people with a user and a password will be able to work on the blog.

[sociallocker] [/ sociallocker]

Create a second level domain

The first thing to do when you want to create a test environment is to create a second level domain that acts as a ” container ” or a website accessible from a url similar to the following:

staging.yourwebsite.it

First of all access in ftp to the wwwroot of your website or the default location of your webserver (Apache, nginx, lighttpd…) and create the “ staging “ folder . This operation can be done using an FTPClient like FileZilla or you can do it via the web using the tools made available by your hosting provider.

For example, I use Netsons as a hosting provider for my websites

 

YOU MAY BE INTERESTED IN …How to install wordpress on netsons provider

if you also use Netsons  you can use the file control interface made available by the hosting itself through the CPanel tool .

Creating a folder is really simple and intuitive

As soon as you have created the ” staging ” folder you are ready to create the second level domain, so, again using the CPanel interface , access the ” Subdomains ”

In the section create a new subdomain by inserting the value ” staging ” in the Subdomain item , leave your Domain in the second item and in the Document Root   get help from the autocomplete of the box to find the folder / public_html / staging you just created.

Click on create and that’s it.

Install https on second level domain

Now that you have created the subdomain you can proceed with the installation of the https Let’s Encrypt protocol , if you do not know what the secure protocol is and how to install it on the main blog I suggest you read this article.

 

YOU MAY BE INTERESTED IN …How to enable (for free) https on wordpress with Let’s Encrypt and netsons

To install it, access the Let’s Encrypt section (Security)

Select the new second level domain and then click on ” issue “. Wait a few seconds and that’s it, the https is installed on your second level domain.

Create staging copy with CPanel

Now that you have set up the second level domain and installed the https protocol you can start creating the staging copy of your blog. If you use the Netsons provider my advice is to use CPanel and the built- in features for creating a staging copy.

Access the “ Software ” section and then “ your site with 1 click! 

Find your live blog

And then click on the “clone” icon

During the setup phase you have to select the second level domain you just created and under the path item write the name of the folder chosen for the second level domain (e.g. staging)

Then leave the default options for creating the db

 

finally click on ” Clone ” and wait for the operation to complete, at the end you will be able to access your new staging section using the chosen domain name and you will see the new section created in the site administration panel

For example, I created a staging copy at https://test.pensando.it

 

 

 

 

that I use to do tests, tests and verifications.

Create staging copy manually

Creating a staging copy manually is a much more complex operation , you will have to do the following manually:

  • copythe wordpress files of your blog to the “staging” folder
  • create a backupof your live database
  • create a newempty mysql database
  • perform a restoreof the live database in the new database
  • modify the wordpress settingsto ensure that all pointers are correct

This is a decidedly more complex operation that requires more advanced skills, my advice is to follow the CPanel procedure If you really want to proceed manually then follow me

 

YOU MAY BE INTERESTED IN …how to install wordpress on LEMP stack (Linux NGINX MySQL php)

I’ll explain some tricks for copying your blog.

·         copy the wordpress files of your blog to the “staging” folder

This step is very simple, you will have to identify all the files contained in the wwwroot of your website and copy them into the new “ staging “ folder . If you use a caching plugin my advice is to clear the cache and disable it before proceeding with the copy.

·         create a backup of your live database

You can create the backup using phpMyAdmin , access the ” Export ” section and click on run

If you have ssh access to your web space, you can make a backup with the command:

mysqldump -u root -p [your database]> [your database] -20200210.sqlAt the end the backup will be in the file [your database] -20200210.sql

·         create a new empty mysql database

You can create a new database using the CPanel tool ” MySQL ”

After creating the database, create a new mysql user with a strong password and assign the full grants to the user for the newly created database.

If you have ssh access then you can create a new database with the following command

CREATE DATABASE [new database] ;Replace the values ​​in square brackets with the ones you want to create for your new staging copy.

·         perform restore the live database into the new database of staging

Using phpMyAdmin you can restore from the ” Import ” section , compress and select your file and then click on ” Run “, wait for the operation to complete.

If you have access in ssh then you can restore the database with the following commands

mysql –database = [newdatabase] -u root -p < [yourodatabase] -20200210.sql CREATE USER ‘ [newuser] ‘ @ ‘localhost’ IDENTIFIED BY ‘ [newpassword] ‘; GRANT ALL PRIVILEGES ON ` [newdatabase] `. * TO ` [newuser] ` @ `localhost`; FLUSH PRIVILEGES;Replace the values ​​in square brackets with the ones you want to create for your new staging copy.

·         change the wordpress settings to get the correct pointers

Now that you have restored the database you will need to change the blog settings to ensure that the pointers are correct.

First, open the wp-config.php file located in the ” staging ” folder and set the correct database values

/ ** The name of the database for WordPress * /define (‘DB_NAME’, ‘ [new database] ‘);/ ** MySQL database username * /define (‘DB_USER’, ‘ [newuser] ‘);/ ** MySQL database password * /define (‘DB_PASSWORD’, ‘ [newpassword] ‘);Then you will have to do the following updates in the database

update wp_options set option_value = ‘ https://staging.yoursite.it ‘ where option_name = ‘siteurl’;update wp_options set option_value = ‘ https://staging.yoursite.it ‘ where option_name = ‘home’;To do this you can use phpMyAdmin or, if you have ssh access to the linux shell, you will first need to run the following commands:

mysql -u root -puse [new database]and then launch the two updates.

How do you see the second way is much more long and complex of the first so if you’re not sure what you’re doing is using CPanel and cloning to be quieter.

Not sure what you are doing? Do you want the advice of a serious and reliable professional?

CONTACT ME

Hide staging copy from search engines

Now that your staging blog is live you will have to hide it from search engines and above all inhibit access to all users who do not have permission.

To hide it from search engines, you can access the following administrative section of the newborn blog: ” Settings ” – ” Reading ” and click on the check ” Discourage search engines ”

To inhibit access to users, you can use a plugin or the integrated ” coming soon ” features of your template (if it allows it).

My advice is to use the plugin ” Coming Soon Page & Maintenance Mode by SeedProd “, a good free plugin that allows you to configure the ” coming soon ” page and then enable full access only for registered users  with users and password.

Conclusions

Now that you have created your staging copy , inhibited user access and discouraged search engines you are ready to run configuration tests, try new plugins, new templates and new settings without the hassle of doing it on your live blog. .

In this article I have told you how to create your own staging copy.  What do you think of my guide ? Did you find it clear ? How about talking about it in the comments ?

 

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment