Setting Up A Magento Staging Area
The best way to test out a new Magento release without potentially destroying your production store is to setup a staging area.
A staging area is a duplicate of your primary store that you can use to see if the upgrade process will go smoothly, and also allow you to use both the frontend and backend of your site to see if everything is running properly.
This article is written with our clients in mind, but the principles will apply no matter where you are hosted or what control panel you're using.
The first thing we want to do is setup a subdomain for our staging store:
1.Login to cPanel for your domain, and click on the Subdomains icon.
2.For both the Subdomain and Document Root, we'll enter staging.
3.Click on the Create button.
Create Staging Database
While we're still in cPanel, let's setup a blank database for our staging store:
1.Go back to the main screen for cPanel, and click on the MySQL Database Wizard icon.
2.For the New Database, we'll enter staging.
3.Click on the Next Step button.
4.For the Username, we'll enter staging, and for the Password, enter whatever you'd like here.
5.Click on the Next Step button.
6.Click on the box next to ALL PRIVILEGES.
7.Click on the Next Step button.
Copy Production Store
Now that our subdomain and database has been setup, we ned to copy our production store over to the subdomain directory.
1.Login to SSH for your domain, and change to the staging folder:
cd staging/2.Copy all of the data from the directory where Magento is installed, which is usually in the public_html directory, to the staging directory:
cp -R ../public_html/* ../public_html/.htaccess .For the next step, you'll need to know the database information for the production store. If you don't remember this, open up the following file:
app/etc/local.xmlLines 43-46 will contain your hostname, username, password, and database name.
Next, we need to copy the data from the production database over to our staging database. We'll be doing this from SSH as well.
mysqldump -u PRODUCTION_DBUSER -p PRODUCTION_DBNAME > data.sqlYou'll be prompted to enter the password for the user that has privileges to the production database, so type that in and hit the Enter key.
This can take a couple seconds to a couple minutes depending on the size of your database, so just wait until it finishes.
Once it finishes, we need to import this data to our staging database:
mysql -u STAGING_DBUSER -p STAGING_DBNAME < data.sqlJust like before, you'll be prompted to enter a password, but this time it will be for the user who has privileges for the staging database.
Update Configuration
Using your favorite text editor, open up the following file from the staging directory:
app/etc/local.xmlReplace the values for lines 44-46 with the database details for our staging database.
Now we need to do is update the Unsecure and Secure URL for our staging store:
1.Login to cPanel for your domain, and click on the phpMyAdmin icon.
2.From the sidebar on the left, click on the _staging link.
3.Click on the SQL tab, and in the text area, run the following command:
SELECT * FROM `core_config_data` WHERE `path` LIKE '%base_url%';4.Click the Check All link and then click on the pencil icon.
5.Update the value fields with the URL for your staging site.
6.Click on the Go button at the very bottom to save your changes.
The best way to test out a new Magento release without potentially destroying your production store is to setup a staging area.
A staging area is a duplicate of your primary store that you can use to see if the upgrade process will go smoothly, and also allow you to use both the frontend and backend of your site to see if everything is running properly.
This article is written with our clients in mind, but the principles will apply no matter where you are hosted or what control panel you're using.
The first thing we want to do is setup a subdomain for our staging store:
1.Login to cPanel for your domain, and click on the Subdomains icon.
2.For both the Subdomain and Document Root, we'll enter staging.
3.Click on the Create button.
Create Staging Database
While we're still in cPanel, let's setup a blank database for our staging store:
1.Go back to the main screen for cPanel, and click on the MySQL Database Wizard icon.
2.For the New Database, we'll enter staging.
3.Click on the Next Step button.
4.For the Username, we'll enter staging, and for the Password, enter whatever you'd like here.
5.Click on the Next Step button.
6.Click on the box next to ALL PRIVILEGES.
7.Click on the Next Step button.
Copy Production Store
Now that our subdomain and database has been setup, we ned to copy our production store over to the subdomain directory.
1.Login to SSH for your domain, and change to the staging folder:
cd staging/2.Copy all of the data from the directory where Magento is installed, which is usually in the public_html directory, to the staging directory:
cp -R ../public_html/* ../public_html/.htaccess .For the next step, you'll need to know the database information for the production store. If you don't remember this, open up the following file:
app/etc/local.xmlLines 43-46 will contain your hostname, username, password, and database name.
Next, we need to copy the data from the production database over to our staging database. We'll be doing this from SSH as well.
mysqldump -u PRODUCTION_DBUSER -p PRODUCTION_DBNAME > data.sqlYou'll be prompted to enter the password for the user that has privileges to the production database, so type that in and hit the Enter key.
This can take a couple seconds to a couple minutes depending on the size of your database, so just wait until it finishes.
Once it finishes, we need to import this data to our staging database:
mysql -u STAGING_DBUSER -p STAGING_DBNAME < data.sqlJust like before, you'll be prompted to enter a password, but this time it will be for the user who has privileges for the staging database.
Update Configuration
Using your favorite text editor, open up the following file from the staging directory:
app/etc/local.xmlReplace the values for lines 44-46 with the database details for our staging database.
Now we need to do is update the Unsecure and Secure URL for our staging store:
1.Login to cPanel for your domain, and click on the phpMyAdmin icon.
2.From the sidebar on the left, click on the _staging link.
3.Click on the SQL tab, and in the text area, run the following command:
SELECT * FROM `core_config_data` WHERE `path` LIKE '%base_url%';4.Click the Check All link and then click on the pencil icon.
5.Update the value fields with the URL for your staging site.
6.Click on the Go button at the very bottom to save your changes.
Thanks for the good writeup. It in truth used to be a enjoyment account it. Look complicated to more introduced agreeable from you! By the way, how could we keep up a correspondence?
ReplyDeletehttps://www.facebook.com/hiremagentodeveloper