Multi-site on Linux

Last modified: June 9, 2009 - 21:51

Software installed:

  • Drupal 6
  • Apache 1.3
  • Red Hat 6.1 (Although other distributions will work)
  • PHP5
  • PostgreSQL 7.4

The process:

  1. Install the Drupal core download from Drupal.org.
  2. Install default Drupal site. I created mine with a "dummyUSER" user and "dummyDB" database with Drupal code in apache/htdocs/drupal
  3. Once you have this working then create a new dir "example1.com" directly under "sites" dir.
    mkdir sites/example1.com
    cp -R sites/default/*  sites/example1.com/
  4. Create a new database "example1DB" and new user "example1USER" in database.
  5. Edit the sites/example1.com/settings.php and change the following:
    • $db_url = 'pgsql://dummyUSER:dummyPSSWDl@localhost/dummyDB';
      to $db_url = 'pgsql://example1USER:example1PSSWDl@localhost/example1DB';
    • (this step is optional, normally Drupal will recognise the base url automatically):
      # $base_url = 'http://www.example.com';
      to $base_url = 'http://www.example1.com'; (Remove the '#' [comment])
  6. cp apache/htdocs/drupal/install.php to apache/htdocs/drupal/sites/example1.com/
  7. Point your browser to www.example1.com. Drupal will show you lot of errors.
  8. Once it shows you errors you are all good. Just point your browser to www.example1.com/install.php and it will present you the installation screen. Install from there on.
  9. Repeat the above process for www.example2.com

Note
If it says the site is offline then your database information in settings.php is not correct. If it says site not found then your base url in settings.php is not correct.

don't forget to update your /etc/hosts file.

bobzibub - October 7, 2008 - 22:49

Add your new url(s) to your 127.0.0.1 entry in /etc/hosts if you have not updated your dns record.
This is because you must use the new url to hit the install.php. Otherwise it can't find relative files, etc.
Use http://newSite.com/install.php, not http://localhost/sites/newSite.com/install.php
Or this will be your error:
PHP Fatal error:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required './includes/install.inc'

Help, please...

sherabdorje - April 14, 2009 - 19:34

I've read a lot of things about multisites but at this point I'm really confused... I would like to have a drupal installation on my localhost and a few more installations sharing my main source code. I'm working with drupal 6.8 over my Debian lenny. I've done what follows:
1- Configured my main db that I called drupal using phpmyadmin.
2- Installed my main site at /var/www/drupal (it is working fine)
3- Created my second db called drupal2 with the same user and pass.
4- Created drupal2 folder at /var/www/drupal/sites/
5- Copied settings.php from /var/www/drupal/default/ to /var/www/drupal/sites/drupal2/
6- Edited these 2 lines:
$db_url = 'mysqli://root:admin@localhost/drupal'; to $db_url = 'mysqli://root:admin@localhost/drupal2';
$base_url = 'http://www.example.com'; to $base_url = 'http://drupal2';
And here started my doubts... I think it isn't right, I'm not sure what's the base url I must use.
After this i pointed my Iceweasel to http://drupal2/install and, of course, the dns could not find the IP address for this name. I probed with all the urls I imagined but the only one gave me some information was http://192.168.52.59/drupal/sites/drupal2/install.php that replied

Warning: require_once(./includes/install.inc) [function.require-once]: failed to open stream: No such file or directory in /var/www/drupal/sites/drupal2/install.php on line 4

Fatal error: require_once() [function.require]: Failed opening required './includes/install.inc' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/drupal/sites/drupal2/install.php on line 4.

I would like to have http://myipaddress/drupal and http://myipaddress/drupal2, http://myipaddress/drupal3, etc. How could I do it.

I'm getting mad with this. Could anybody help me, please...
Please, sorry my English, I hope you understood me...
Thanks

How to have your sites setup

2think - May 17, 2009 - 23:42

Hi Sherabdorje,

I hope these tips help. From your explanation (sorry, haven't been on Drupal in a while thus my delay in answering).

Conceptually, I think you're missing some elements. For example, your drupal2 folder should probably be named drupal2.com (if that's what you decided to use) since Drupal's documentation suggests as much.

Next, you need to setup your virtual hosts file appropriately (if you're using Apache).

So if you're using multi-site Drupal, your httpd.conf or vhosts.conf will have your sites in site1 - /var/www/drupal/sites/xxx.com. Then another site as /var/www/drupal/sites/yyy.com (just one suggested way of doing it, there may be others who prefer another but I think this is more in line with what Drupal recommends)

You need to edit your /etc/hosts file to point to that on 127.0.0.1, something like this format in your /etc/hosts file.

127.0.0.1 drupal2.com
127.0.0.1 drupal3.com

Don't forget to do the above editing as root to ensure you have permission to open, write and save your /etc/hosts file.

In summary, it seems you need to fix your folder names under multi-site, configure your various site directories for your virtual hosts and then edit your own /etc/hosts file. None of this is daunting or impossible.

 
 

Drupal is a registered trademark of Dries Buytaert.