Crucial Hosting

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.

  • Applies To: All Services
  • Difficulty: Medium
  • Software Required: Magento
AWS
This article was last updated on November 4th, 2015

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.

Jump To Section

Create Staging Sub Domain

The first thing we want to do is setup a sub domain for our staging store:

  1. Login to cPanel for your domain, and click on the Sub Domains icon.
  2. For both the Sub Domain 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 sub domain and database has been setup, we need to copy our production store over to the sub domain 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.xml

Lines 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.sql

You'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.sql

Just 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.xml

Replace 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.

Upgrade Staging Store

Please refer to the software vendors support resources for the most current instructions on how to upgrade Magento application. This can be a complex procedure and the software vendor will always supply the latest information necessary.

After You Upgrade

After you upgrade your store, don't assume everything is working correctly because your site is coming up without errors. Use this time wisely to go through your entire site, including the backend:

  • If your navigation has dropdown items, make sure they work
  • Search for a product to see if anything comes up in the results
  • Make sure you can add a product to your cart and purchase it
  • Check if your layered navigation is intact
  • Create or edit an existing product, making sure you can save it

If you do come across any errors, check the community forum to see if others are experiencing the same issue.

If you can't find anything, create a new thread to see if anyone can assist you.

It's also a good idea to search the bug tracker. You can even help by submitting a new bug if you don't find anything.

Professional hosting platform starting at $10/mo

View Plans