First and foremost nobody likes to work on production applications. Therefore it is advised and good practice for someone to set-up separate stores, my structure is as follows:

  • dev.magento.local -> Development store;
  • stage.magento.local -> UAT/QA store;
  • magento.local -> Production store;

Meanwhile the store is tracked in source control, including the app/etc/local.xml, which is the first conflict of this structure. Nevertheless once the Magento installation process has complete and we have the local.xml, the idea was to:

1) Export the recently installed however fresh Magento store.

icanhas$ mysqldump --single-transaction magestore_dev > magestore_dev.dmp.sql

2) Then import the structure for the remaining environments.

icanhas$ mysql -u'magestage_user' -p'magestage_pwd' < magestore_dev.dmp.sql
icanhas$ mysql -u'mageprod_user' -p'mageprod_pwd' < magestore_dev.dmp.sql

3) The new environments need their urls corrected, although that's beyond this question let's assume they've been done.

4) As previously mentioned, we need to solve the conflict with app/etc/local.xml so I created the following directories:

  • /app/etc/development/local.xml -> Moved local.xml here;
  • /app/etc/staging/local.xml -> Copied development/local.xml here;
  • /app/etc/production/local.xml -> Copied development/local.xml here;

5) I corrected the database credentials for each environment, this was committed to the repository.

6) Finally I had so create the following symbolic links:

  • On dev.magento.local; app/etc/local.xml -> app/etc/development/local.xml;
  • On stage.magento.local; app/etc/local.xml -> app/etc/staging/local.xml;
  • On magento.local; app/etc/local.xml -> app/etc/production/local.xml;


  1. Could there be anything bad about using this method?
  2. After installation does Magento write to this file at any point?

Any advice would be greatly appreciated.

  • Damn, that's clever.
    – benmarks
    Jan 11, 2014 at 15:01

3 Answers 3


In my opinion, local.xml is not an issue you need to be tackling in version control. It's also questionable from a security perspective.

I recommend you just place /app/etc/local.xml in .gitignore and set it up once on your individual environments.


Magento shouldn't write to local.xml after installation (I've never seen that behavior). The Bad(TM) thing about your approach is that's it's typically advised to avoid storing configuration files in your project's repository.

One reason is related to security. Anyone with access to the repository now has some sensitive information about your infrastructure. It's could be unlikely that you'd be targeted or it would happen but people tend to follow the convention because it's not that difficult to do so.

If you're team/organization is expected to grow then it's a good Idea to separate application code and configuration. Which can then be managed with the appropriate technologies.


I can't imagine anything bad about that so long as the additional files aren't world accessible (which they wouldn't be in a default install). I can't think of any instances where the core writes to local.xml (willing to be corrected on that), some extensions might though, but this should be a non-issue with your set-up anyway, as it should write to the relevant file via the symlink anyway.

Personally we tend to keep local.xml out of source control, for development I just copy the local.xml from the last project I worked on and modify the database name, as this is all that tends to change. And production / staging we just create it on the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.