There are two ways to do this. From your question, it sounds like you have this structure currently:
/home
... /public_html
... ... wp-config.php <- for site1
... ... /site1
... ... ... /wp-admin
... ... ... /wp-content
... ... ... /wp-includes
... ... /site2
... ... ... /wp-admin
... ... ... /wp-content
... ... ... /wp-includes
... ... ... wp-config.php <- for site2
And what you want to do is also move the wp-config.php
file for your other sites out of the site root as well. You're correct in pointing out that this will lead to some conflicts because every site will try to include wp-config.php
but can't all use the same one.
The bigger problem is that there is no way to use wp-config.site1.php
or wp-config1.php
or any other variation to keep things separate without hacking core.
If you take a look at the code in wp-load.php
you'll see this:
if ( file_exists( ABSPATH . 'wp-config.php') ) {
/** The config file resides in ABSPATH */
require_once( ABSPATH . 'wp-config.php' );
} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! file_exists( dirname(ABSPATH) . '/wp-settings.php' ) ) {
/** The config file resides one level above ABSPATH but is not part of another install*/
require_once( dirname(ABSPATH) . '/wp-config.php' );
}
WordPress will only look one directory past its current location and will only look for wp-config.php
.
Your best bet would be to push everything up one level further to give yourself some separation. Then point your Apache vhosts file at the new folder locations. So set your directory structure up like this:
/home
... /public_html
... ... /site1
... ... ... wp-config.php <- for site1
... ... ... /wordpress
... ... ... ... /wp-admin
... ... ... ... /wp-content
... ... ... ... /wp-includes
... ... /site2
... ... ... wp-config.php <- for site2
... ... ... /wordpress
... ... ... ... /wp-admin
... ... ... ... /wp-content
... ... ... ... /wp-includes
Your vhosts file will then point www.site1.com
to /home/public_html/site1/wordpress
instead of /home/public_html/site
. Yes, it's a bit more convoluted, but the only way you can avoid this issue.
wp-config.php
file through the browser anyway ...wp-config.php
to the same level as/wp-includes
... not to the level of/home
below/public_html
. You're moving things in the opposite direction.