Community Documentation

Multi-site on Linux

Last updated March 4, 2011. Created by jbrauer on August 4, 2008.
Edited by Fiable.biz, cvdenzen, stabilpa, dellintosh. Log in to edit this page.

Software installed:

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

The process:

(You may get more specific explanation in your Linux distribution documentation. https://help.ubuntu.com/community/Drupal
http://wiki.mandriva.com/en/Local_multi-site_installation_of_Drupal
etc.)

  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.

Comments

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

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'

/etc/hosts hell yeah!

I'll be damned if this is not the first time someone actually told us to edit the freakin' /etc/hosts file! I have spent just too much time trying to get multisite running. Maybe I overlooked it, maybe its just too obvious, whatever. This just did the trick...

sudo gedit /etc/hosts

And adding a line to

127.0.0.1      example.com

Save, reload

Thanks a lot

Help, please...

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

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.

Permissions problem

If I remember correctly, that is a permissions and ownership problem.

Make sure the settings.php and dbconfig.php files are writable at installation time. (The installation scripts change their permissions once they are done with them.)

dbconfig.php must also be in group www-data.

Here are my details:

settings.php ->
user: root
group: root

(Again, the file should initially be set to "Can read & write" for all categories at installation time.)
After installation is complete, the permissions ought to become:
Owner: Can read & write
Group: Can read
Others: Can read

dbconfig.php ->
user: root
group: www-data

After installation, the permissions ought to be:
Owner: Can read & write
Group: Can read
Others: Forbidden

Hints:
When an Ubuntu user, I use "sudo nautilus" to become the root user and change file permissions from the file manager.

When a Kubuntu user, I use "sudo dolphin" to become the root user and change file permissions from the file manager.

Perspectoff
Ubuntuguide.org/wiki/Kubuntuguide

Incomplete description

I understand that the point of this is to show us how to set up a multi-site configuration and not to teach us how to use Apache or Linux. I really appreciate people taking the time to try and explain these things. The problem is, there is such a mess of incomplete instructions, instructions with errors, deprecated instructions, that it's very hard for me to find good help in making this happen. I knew right away that when I pointed my browser to www.example1.com it would not work. I saw a reply stating exactly what I expected and how to remedy that. I also appreciate that very much, but I don't know how to do it. I've been working on this for two days and reading every piece of material I can find but I run into a wall everywhere I turn.

If I get no help from posting this comment here, can someone please at least heed this: If you are going to write instructions or tutorials, please make them complete and detailed from start to finish. List the steps you will use at the beginning of the instructions, list tools needed, and if your instructions assume a certain level of aptitude with the tools in use, please say that at the beginning.

Again, I appreciate anyone who has attempted to help by writing these instructions and I hope the one who wrote these doesn't take this comment personally because it applies to most of the instructions and tutorials I've tried reading in the past two days.

If you have any help for me, please feel free to direct me to documents I may have overlooked. I'm happy to read.

Thank you.

I feel your pain

Ubuntuguide:

Multiple Drupal site installation on Ubuntu:

http://ubuntuguide.org/wiki/Drupal6_tips#Multi-site_Installation

Kubuntuguide:

Multiple Drupal site installation on Kubuntu:

http://www.kubuntuguide.info/index.php/Drupal6_tips#Multi-site_Installation

Perspectoff
Ubuntuguide.org/wiki/Kubuntuguide

Nice tutorial. Now my

Nice tutorial. Now my question is that do anyone know how to do this on shared server ? I have web-space at hosting company but they do not provide me any change in httpd.conf or virtual-host file. If anyone knows other way than do let it know here. It will be very helpful for all people who are using shared hosting.

Clear explination

I found the 10 minute multisite tutorial, http://drupal.org/node/138889#comment-2510252 to be clear and to work for me.

Naming the sites the proper way...

My additional sites are going to live in a subdirectory rather than a subdomain. Do I have to name my subdirectory in the following format "example1.com.subdir" or can I just name it "subdir".

The problem with example1.com.subdir is that we are on a test server migrating all of our sites to drupal, and the URL example1.com is current being used for the live site. Or will that not interfere?

How install multi site in lamp server

I use Lamp on ubuntu 10.04 ,How i can install multi site in drupal on that enverment ?I am new to drupal.:)

earhba

Page status

Needs updating

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Site administrators

Installation guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here