How much work you will have to do to make this happen will depend on the details and flexibility of your CMS' codebase.
When I make sites, I like to use the Apache
SetEnv directive in each of my site's
vhost files. E.g.
SetEnv BASECMS /var/lib/basecms/
SetEnv SHAREDLIBS /var/lib/sharedlibs/
SetEnv CLASSPATH /source/site1/classes/
SetEnv VIEWPATH /source/site1/views/
SetEnv CONFIGPATH /source/site1/configs/
SetEnv _JSCRIPTS /source/site1/www/_jscripts/
SetEnv _IMAGES /source/site1/www/_images/
SetEnv _CSS /source/site1/www/_css/
I can then reference these environment variables in my
// php paths - all have trailing slashes
define('BASECMS', $_SERVER['BASECMS']); // in /var/lib/basecms
define('SHAREDLIBS', $_SERVER['SHAREDLIBS']); // in /var/lib/sharedlibs
define('CLASSPATH', $_SERVER['CLASSPATH']); // in /source/site1...
define('VIEWPATH', $_SERVER['VIEWPATH']); // in /source/site1...
define('CONFIGPATH', $_SERVER['CONFIGPATH']); // in /source/site1...
FYI - these paths are outside each site's document root for security - the document root for each site is
Thanks to passing all the site-specific vars from apache vhost (analogous to the "client id" you mentioned), my site's structural code (
/var/lib/...) stays the same and will cascade down. Site-specific code is picked up via references to the
This would all work great if I had no other files which needed to be inside the domain folder... but unfortunately there are data files that need to be in domain folder.
I will make some more definitions, specifically for the stuff I need to have shared:
// js, css, image paths some unique to each site, some shared/library used by all
define('LIBRARYJSPATH', JSPATH.'library'); // to be symlinked under docroot
define('SHAREDJSPATH', JSPATH.'shared'); // to be symlinked under docroot
then I will make specific symlinks inside the docroot, back out to the shared locations:
ln -s /var/lib/libjs /source/site1/www/_jscripts/library
ln -s /var/lib/basecms/jscripts /source/site1/www/_jscripts/shared
The end result is a directory structure accessible to my app that contains shared and site-specific code and assets.
tl;dr - yes, depending on your app's limitations you can use
SetEnv in apache to let your app see both common and unique code, and use individual symlinks underneath docroot to 'merge' common and unique assets.
This topic is a favourite of mine - if you want to paste more specifics of your environment happy to get into specifics with you.