I needed to create a Magento Staging Area for both common development tasks and testing the latest upgrades.
In order to create the staging area for my Magento store I’m going to create a mirror of it at a subdomain. I host on my own Linux server and use Godaddy to manage my domains.
My main Web site will be referred to as www.domain.com. I’ll be creating the Magento development site at dev.domain.com. Below is a step by step documentation of the steps taken to create my Magento staging area using virtual host.
Create CNAME Record:
=> login to Godaddy
=> select Domains : My Domains
=> select your domain (domain.com)
=> select Total DNS Control and MX Records
=> select Add New CNAME Record
=> enter (dev) as Alias Name
=> enter (domain.com) as Host Name
Create Staging Files:
=> copy live file directory to dev
=> run cp -R store.domain.com dev.domain.com
Create Staging Database:
=> create new Dev database
=> dump Production database
=> mysqldump –opt –user=liveuser –pass=livepass livedbname > livedbname.sql
=> load Staging database
=> mysql -u devuser -p devdbname < livedbname.sql
Setup Virtual Host in Apache:
=> locate conf file (ie httpd.conf, vhosts.conf)
=> create VirtualHost entry for dev.domain.com
=> locate apachectl
=> run ./apachectl configtest
=> run ./apachectl restart
Sync Staging Site DB Credentials:
=> editapp/etc/local.xml
=> edit lines
=> edit lines
=> edit lines
Sync Staging Site Database Settings:
=> login to MySQL dev database
=> find config to edit
=> SELECT * FROM `core_config_data` WHERE `path` LIKE ‘%base_url%’;
=> update path web/unsecure/base_url
=> update path web/secure/base_url
Cleanup Staging Site:
=> rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
=> rm -rf var/cache/* var/session/*
It might take a while to shake out the cache, but that should basically get you a Magento staging server — a snapshot of your live Magento site.
** Note: I pulled my hair out for hours trying to figure out why the dev url was not printing correctly. It just seemed that whatever I did the system wouldn’t pick up the new base_urls. What I did was restart apache which I’m assuming cleared cache and allowed for the update base_url to be picked up. Also, make sure var directory is writable.
7 Responses to “How to Create a Magento Staging Site”
Jools
I have published information with an alternative solution that means you don’t have to update the base_urls for the staging site.
http://maglife.co.uk/2009/03/28/magento-base-urls-and-devstaging-installations/
Tacitus
…great solution! Thanks a lot! …BUT, don’t forget to modify your .htaccess file (-> RewriteBase) when you use mod_rewrite!
Sean
Thanks for the article. I have a quick question on it though. At the very end of the article you mentioned that you ” pulled my hair out for hours trying to figure out why the dev url was not printing correctly”. When you say “printing correctly” what does that mean. Did that mean the pages pulled up fine but that the URL in the browser was wrong? Or was it that you couldn’t pull of the correct pages even with the right URL in the browser?
Thx
ed
Sean, what I think I meant was that Magento was not using the new dev url as the base url. It was stuck on using the production full url. So for instance, I could see the site at dev.store.com, but the category/page links were still using the production url.
mn1423
Hi Ed,
In general practice what should be the time expected to built this staging server.
What are the parameters on which this depends? Please let me know a rough time.
Thanks
MN.
ryan
how about the companion article for this topic… publishing back to the live www site from the dev staging server? I’d love to see the steps and specific folders to publsih back and db copy/update steps recommended to do the reverse order
kiran
I am in the process of creating a staging site for Magento. Have made all the changes for database connection along with changes in secure and unsecure URL’s . On trying to open my URL it is showing a blank screen. What can be done for this ?