So I just figured out how to get Drupal’s multi-site configuration working on my Rackspace Linux server.
Let’s say your Drupal core is located at my-drupal-core.com. Install Drupal there, this will be your master copy.
Within your ’sites’ folder, create a folder for each domain you will want to run off this core installation. Let’s say we’ll make a Drupal site, based on this core, which will be drupal-slave.com. So, within your sites folder, create a drupal-slave.com folder. I prefer using a different database for each site. So create the database for the slave site, and then copy the settings.php file from your sites/default folder, alter it for your slave database, and put it into the drupal-slave.com folder. While you’re in there, create a files folder, you may need to change its permissions to 777.
So, your drupal-slave.com folder should look like this:
sites
-- drupal-slave.com [folder]
-- settings.php
-- files [folder]
-- modules [modules specific to this domain]
-- themes [themes specific to this domain]
Now, on my server, every domain has a vhost.conf file, located inside a domains conf directory - this is at least how Red Hat does it. If you have a conf folder, but no vhost.conf file, go ahead and create it - you’ll likely need to login as root to do this.
Now, within your vhost.conf file (for drupal-slave.com, in this scenario), you’ll need to do something like this (alter for your own needs):
DocumentRoot /httpd/vhosts/my-drupal-core.com/httpdocs<Directory /httpd/vhosts/my-drupal-core.com/httpdocs> php_admin_value open_basedir /tmp:/httpd/vhosts/my-drupal-core.com/httpdocs AllowOverride All </Directory>
Then, (gracefully) restart Apache - viola! Works for me at least. By the way, the AllowOverride All is to allow the my-drupal-core.com’s .htaccess file to work on all slave sites. The /tmp directory allows the slave site to write to the tmp directory for file uploads. Hope this helps someone.
Security
Note that with a multi-site setup, you really need to be careful of who can use the PHP filter (preferably, nobody). Reason being you can use PHP to read/output any domain’s settings.php file and gain access to the database username and password for any domain sharing the Drupal installation, including the master domain. Careful! This alone makes me think I won’t be using a multisite setup for high profile sites, or any site I’m not directly managing.
Yeah, that’s pretty much how we do it. However we keep all our clients Drupal data in their own folders in our main “sites” directory, and then point symlinks to that from within the Drupal sites. We also add symlinks to their folders for any domain aliases they might have.
where does vhost.conf belong?
my code base is located here: /home/site1/public_html/drup
and my other site is located here: /home/site2/public_html
I have system links setup on site2 linking to site1 for the following directories: modules, themes, misc, and sites/site2/files
i get this error and im guessing its cuz site2 can’t access site1 files.
Warning: chdir() [function.chdir]: open_basedir restriction in effect. File(/home/xxx1/public_html/drup/) is not within the allowed path(s): (/home/xxx:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/xxx2/public_html/index.php on line 2
@patc - on my Red Hat dedicated server, there’s a conf directory in each domain’s directory. So, it would be /root/path/to/domain.com/conf
If you’re running a different flavor of linux, then it’s probably different.
From there, I need to create a vhost.conf file, fill it out like the example above so that it points to the root installation of whichever domain the drupal files are in, then create a matching domain folder in drupal’s “sites” directory, then restart the apache to pick up the new config.
So basically, if your drupal is installed here: /home/site1/public_html/drup
Then your second site needs to define that as it’s root directory somehow, instead of using the default of /home/site2/public_html
Hope that helps.
good informations. thank you