How to Set Up Staging Environment in Magento 2

Magento developers may be tempted to launch their online store, set up the initial configuration, and get going!

However, it is very much likely that you may face some error, install a poor quality extension, or something may go wrong that will disrupt the store functionality.

Therefore, it is essential to set up staging environment in Magento 2.

It is like playing with fire for a Magento developer to perform tasks such as upgrade, migrate, or customize in live store rather than in the staging environment.

The Staging environment provides a near-production environment that includes a database, web server, and all the services.

You can use the staging area to see if, say, the upgrade process will go smoothly or not! It allows using both the front and backend of your site to see if everything is running properly.

Check the whole staging environment after any modification, upgrading to latest Magento 2 version, or installing a Magento extension. If everything works properly in the staging area of a primary store, then follow the same in your live site.

Now that you know how much necessary it is to set up staging environment in Magento 2, here’s the exact method for the same.

Just follow the below steps, and your staging area will be ready to execute.

Steps to Set Up Staging Environment in Magento 2:

There are four main basic steps to set up the staging environment of your primary store.

  1. Create Staging Sub Domain or Create Subfolder Under Your root Directory
  2. Create Staging Database
  3. Copy Production Store
  4. Update Configuration in Database

Create Staging Sub Domain or Create Subfolder Under Your root Directory

Setup a subdomain 

Login to your hosting server(i.e., cPanel) for your domain, create a subdomain or create the subfolder under your root directory.

Create Staging Database

Setup a blank database

  • While we’re still in the hosting server, we first have to set up a blank database for our staging store:
  • Enter staging for the new database.
  • For the Username, we’ll enter staging too.
  • Enter whatever you’d like in the Password field.

Copy Production Store

Copy our production store over to the sub domain directory

  • Copy the main store’s Folders and Files.
    • For example :
  • Next, we need to copy the data from the Main Site’s database to our staging database. We’ll do this from SSH as well.
  • Now, you’ll be prompted to enter the password for the user with privileges to the Main Site database, so type that in the password field.
  • Press the Enter key.
  • It can take a couple of seconds or a couple of minutes, depending on your database’s size.
  • Just wait until it finishes.
  • Once it finishes, we need to import this data to our staging database:
  • You’ll be prompted to enter a password; this time, it’s for the user who has privileges for the staging database.

Update Configuration in Database

Update the Unsecure and Secure URL for our staging store:

Pass the below commands:

Here you go, once you set up the staging area, you can modify code, content as per your requirement without the fear of stopping the live site.

Additionally, upgrading a Magento store is one of the most complex tasks of Magento. So, use the above steps to set up the staging environment and then upgrade your store safely.

Still, if you find any difficulty while upgrading your store, Meetanshi’s experienced and certified developers offer professional Magento Upgrade Service to upgrade your store to the latest Magento 2 version without any data loss and zero downtime.


If you find any difficulty while setting up the staging area of your Magento store, do share that with us.

I’ll be happy to help you out.

Thank you.

(based on 14 Reviews)
How to Set Up Staging Environment in Magento 2

Kishor Chhugani

He is a Magento developer at Meetanshi with a jolly, extrovert, & friendly personality. He loves playing cricket and is a passionate foodie!


Leave a Reply

Your email address will not be published. Required fields are marked *