How to move local.xml outside the doc root
This is an old revision of the document!
*DONE AFTER SUCCESSFUL INSTALL*
Tested with Magento Versions:
1.3.1.1
1.4.0.1
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.
<config>
<global>
<install>
<date><![CDATA[Fri, 26 Feb 2010 20:29:02 +0000]]></date>
</install>
</global>
</config>
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
*/
$doc_root = getcwd();
$arrDocRoot = explode( "/", $doc_root );
$arrDocRoot[ count( $arrDocRoot ) - 1 ] = "includes";
$arrDocRoot[] = "etc";
$etc_dir = implode( "/", $arrDocRoot );
$options = Array( 'etc_dir'=>$etc_dir );
Mage::run($mageRunCode, $mageRunType, $options);
/******************************************************************************/
Notes:
On different versions the Mage::run in the index.php may look like this
Mage:run();
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 1.3.1.1
public static function run($code = '', $type = 'store', $options=array())
so we would change:
Mage::run();
to
Mage::run( "", 'store', $options );


