How to move local.xml outside the doc root

Last modified by Matt Alexander on Thu, June 24, 2010 15:17
Source|Old Revisions  


  Tested with Magento Versions:
  1. Create 'includes' directory outside the doc root
  2. Copy the whole app/etc folder to the new include dir
      Note that these instructions are for the whole etc folder
      not just the local.xml
  2. chown -R apache:apache includes
  3. chmod -R 700 includes
  4. Delete all files/dirs from the app/etc folder except local.xml
      The Magento installer is hardcoded to check 
          the app/etc/local.xml for the install date
          and will try to run the installer again if 
          it is not present.
  5. Remove everything from the app/etc/local.xml except
          the install date section. It should now look something
          like this.
                  <date><![CDATA[Fri, 26 Feb 2010 20:29:02 +0000]]></date>
  6. Make the following edits you your index.php file
      // comment out or remove the following line
      //Mage::run($mageRunCode, $mageRunType); 
      * move etc dir outside of doc root
      *   this assumes that etc directory is located
      *   one level up from doc root. 
      *   ../includes/etc 
      *   code should be edited if etc folder is moved somewhere else
          $options = array('etc_dir' => realpath('../includes/etc'));
          Mage::run($mageRunCode, $mageRunType, $options);


  On different versions the Mage::run in the index.php may look like this
  Check the function parameters for the run() function in app/Mage.php
  Some sites may already set these values in the index.php, if not 
      use the defaults specified in the function definition
  Example from Version
      public static function run($code = '', $type = 'store', $options=array())
      so we would change:
          Mage::run( "", 'store', $options );