views:

140

answers:

1

I am working on a ecommerce based on MagentoCommerce. I use 3 environments: dev (on my local machine), staging and production (both on my dedicated server).

The problem is that when I want to switch from local to staging, I have to edit my hosts file to point the domain used by Magento to my server's IP. However, this is time consuming and I was wondering what other magento developers out there were using as a strategy to not always have to change the hosts file when switching from an environment to another. Plus, when my ecommerce goes into production, I'll have to deal with 2 environments on the same IP.

The best would be if Magento had the domain hardcoded in only one file. That way I could keep different config files in each environment. Is that the case ? Otherwise, what places are domains "hard coded" ?

+3  A: 

I'm running Magento on a Production server and a number of development and test domains.

The domain isn't hardcoded in any file - the domain is all in the database.

You have to change the secure base url and the unsecure base url when you move from server to server. Both of these are stored in the database and can be changed in the web based administration screens. When moving the database from one host to another, I use a script that does little but update these values. Here's the SQL you need to update these values:

update core_config_data
set value='http://whatever.com/'
where path='web/unsecure/base_url';

update core_config_data
set value='https://whatever.com/'
where path='web/secure/base_url';

You may also want to pay attention to the local.xml file where the database connection is configured. I'm sure that you'll want to have the different instances using different databases. In my configuration, I leave this file out of source control, and configure it just once for each instance.

Laizer
+1 this is the way I do it as well. Other config items you may need to script are things like Paypal and Google settings (I have these set to the test servers in dev, but obviously need to be the real ones when pushed to live)
Paolo