The store will not work correctly when cookies are disabled.
JavaScript seems to be disabled in your browser.
For the best experience on our site, be sure to turn on Javascript in your browser.
We use cookies to make your experience better.
To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies.
Learn more.
Allow Cookies
Home
Blog
How to Set Up Staging Environment in Magento 2
How to Set Up Staging Environment in Magento 2
October 16, 2021
The Online Helper
Steps to Set Up Staging Environment in Magento 2
Follow the following steps to Set Up Staging Environment in Magento 2:
Create Staging Sub Domain or Create Subfolder Under Your root Directory
Create Staging Database
Copy Production Store
Update Configuration in Database
Create Staging Sub Domain or Create Subfolder Under Your root Directory
Sign in to your hosting server to set up your domain, create the subdomain or subfolder under the root directory.
Create Staging Database
Create a blank database for the staging store.
Set the username for the database.
Set the password for the database.
Assign ALL PRIVILEGES for the database.
Copy Production Store
Copy the production store in the subdomain directory.
You can copy the files and folders of the store by command.
zip -r mtbackup21012021.zip app/ bin/ dev/ downloads/ generated/ info/ lib/ phpserver/ setup/ update/ vendor/
By SSH now we will copy the data of the database to our staging database.
mysqldump -u [database_user] -p [database_name] > db_name.sql
Enter the password in the field of Password.
Now press the Enter key, it will take some time according to your database size.
When it is finished, import the data into our staging database.
mysql -p -u STAGING_DBUSER STAGING_DBNAME < db_name.sql
Update Configuration in Database
Now update the secure and unsecure URL in the database for the staging store
Run the following queries,
SELECT * FROM `core_config_data` WHERE `path` LIKE '%base_url%';
UPDATE core_config_data SET value = 'staging_url' WHERE path LIKE 'web/unsecure/base_url';
UPDATE core_config_data SET value = 'staging_url' WHERE path LIKE 'web/secure/base_url';
If you are looking for Magento Developers, visit
Magento Developer Agency .