By tmallen on
What's the best way, assuming there's any way, to have a Drupal multi-site installation work in both dev and production when a site is identified by subdomain? For instance, it's easy to name your site folder "mygreatdomain.org" and have dev.mygreatdomain.org point to the dev server: Subdomains are a convenient workaround. But this is not possible if the sites folder must be named "sub.mygreatdomain.org."
So, is there any way to properly do this? Also, is there a better way, period, to do dev/production environments than using subdomains for dev, and site folders with no subdomain?
Any help would be greatly appreciated, as well as advice on other dev/production environments.
Comments
So, you need
So, you need "sub.mygreatdomain.org" for the production sites?
Why can't you have "devsub.mygreatdomain.org" for the dev sites, with different "sites/" subdirectories for each site's settings.
If the problem is the "files" directory paths, just don't use "/sites/sub.mygreatdomain.org/files" for the files. It is fine to use "files/site-nickname". There is no benefit in putting the uploads directory under sites/real-domain-name/.
I had a similar problem that
I had a similar problem that required patching the drupal core.
We have dev/prestaging/staging/integration/production servers
we have URLs like
dd.dp.dev.example.com
dd.dp.prestaging.example.com
dd.dp.staging.example.com
dd.dp.integration.example.com
dumbdoctors.com
The site's url is scanned and then, a configuration array is scanned to see what folder in the sites directory to use.
in a file dp.site.config.inc we have the following:
The main key "dumbdoctors" will be used as the directory name in sites, "drupal/sites/dumbdoctors/settings.php". The keys 'production, staging, integration, etc' are to determine which database connection we should establish. Finally the 'default' => 'dd.dp.integration.example.com' says this is a normal database connection and the URL is dd.dp.integration.example.com. This also allows for Master/Slave Database partitioning, e.g. ''slave' => 'dumbdoctors.com dumbdoctors.example.com'' says for those 2 urls 'dumbdoctors.com and dumbdoctors.example.com' we should use master slave setup. We also have to setup a different DB connection based on the URL, so we have an array of DB connections, notice the key 'local' above match with key 'local' below and so on
Finally I had to make a big patch to drupal's bootstrap process to run my custom code.
That code scan the URL and finds the Database to connect to.
There are some custom bits you probably wouldn't need, like the $sc_conf variable that contains settings such as to enable SSL connections only on production
Also
$user_entered_url = preg_replace("/^work-[^.]+\./","",$_SERVER['HTTP_HOST']);removes our custom dev URLs for users working in sandboxes, you could remove that.finally the
$db_key == 'slave'bit of code is for our other custom patch to drupal to allow master/slave database partitioning, which requires a separate patch.I'm also interested in any other configuration changes you may have required. This setup has been working great for us for a while now.