I was searching for the way to create multisite for several days, but the result is I only know I have to create structure (sites/example1.com, sites/example2.com). But what next?

Sorry, if this seems simple or silly question. But I really have no idea how to actually make subsites work? How to make multisite system work?

If you have experience of making multisite, please write step by step installation instruction. Or if there is any, just give a link. Hope, it would help many people like me.

Comments

-Anti-’s picture

> sites/example1.com & sites/example2.com

For that, you do realise that you are going to have to register and pay for those extra domain names?
Maybe that's the 'what next' part you're missing?

After registration, when you add them to your webhost account ('add' not 'park'), you specify that they redirect to the corresponding folders (ie. site/example1.com). Then you visit http://example1.com, and when redirected Drupal sees that you don't have a settings.php for it, and starts the install process. Voila - you have a multisite.

The next method, if you only have one domain, is to create subdomain multisites.
The folders are: sites/sub1.domain.com & sites/sub2.domain.com
However, this is more tricky, because then you have to create real subdomains, and redirect them to these drupal folders. Cpanel-11 now actually allows you to do that when you set-up the subdomain I think. However, depending on your host you may have to use 'symlink' or 'virtualhost' methods of redirection.

The last way, is to use folders: sites/example1 & sites/example2
No redirection is needed here. You access the multi site with: http://domain.com/example1
Drupal sees that you don't have a settings.php file and starts the install process.

Before anyone writes a walk-through for you, you'd need to specify which method you want to use. And because hosts and situations vary so much, you'll need to say which host you're using and what kind of control panel you have.

Mavros Gatos’s picture

> For that, you do realise that you are going to have to register and pay for those extra domain names?
Yes.

By the way, should multisite installation start from scratch (with no default site installed), or after I have default site installed and running?

> The last way, is to use folders: sites/example1 & sites/example2
Ok, I created folders, but what should be in them?
You write "Drupal sees that you don't have a settings.php file and starts the install process." So, I shouldn't put settings.php in subsite folder?
But Drupal INSTALL.txt says: "Each subdirectory must have a 'settings.php' file which specifies the
configuration settings."

> hosts and situations vary so much, you'll need to say which host you're using and what kind of control panel you have.
Virtual hosting,
Control panel: Direct Admin

Anonymous’s picture

Hy Mavros Gatos,

There are various ways to set up a multi-site installation, but this is how I do it:

Currently I am working on a multi-site installation with one codebase and two subsites. In /var/www I have three directories:

- codebase
- subsite1
- subsite2

I suppose you want to share themes and modules amongst all the subsites so we need to create these directories under codebase/sites/all:

- codebase/sites/all/modules
- codebase/sites/all/themes

Next create for each subsite the following directories:

- codebase/sites//files
- codebase/sites//modules
- codebase/sites//themes

Each uploaded file on subsite x will be stored under files, and each subsite can also have an own theme or own modules.

Remember we had three directories in our root? Now we need to set up each subsite in that directory. Create the following directories:

- /var/www/subsite1/sites/subsite1.com/files
- /var/www/subsite2/sites/subsite2.com/files

The files directory need to be user and group writable.

Copy some important files to each subsites root folder:

- cp /var/www/codebase/.htaccess /var/www/subsite1/
- cp /var/www/codebase/robots.txt /var/www/subsite1/
- cp /var/www/codebase/.htaccess /var/www/subsite2/
- cp /var/www/codebase/robots.txt /var/www/subsite2/

Create for each subsite a settings.php file (add the proper database settings!!!):
- cp /var/www/codebase/sites/default/settings.php /var/www/codebase/sites/subsite.com/

Last but not least lets create some symbolic links (repeat this step for each subsite):
- ln -s /var/www/codebase/misc/ /var/www/subsite1/misc
- ln -s /var/www/codebase/modules/ /var/www/subsite1/modules
- ln -s /var/www/codebase/themes/ /var/www/subsite1/themes
- ln -s /var/www/codebase//sites/all/ /var/www/subsite1/sites/all
- ln -s /var/www/codebase/sites/subsite1.com/files/ /var/www/subsite1/sites/subsite1.com/files
- ln -s /var/www/codebase/sites/subsite1.com/modules/ /var/www/subsite1/sites/subsite1.com/modules
- ln -s /var/www/codebase/sites/subsite1.com/themes/ /var/www/subsite1/sites/subsite1.com/themes

The final step is to create in each subsites root directory these files: cron.php, index.php, install.php, update.php and xmlrpc.php.
Each files content looks like this (change with the proper filename!):

	chdir('/var/www/codebase/');
	include('./index.php');

This is it. I suppose you know how to set up a virtual host? Just point your DocumentRoot to /var/www/subsite and select the ServerName www.subsite.com

I hope my post is helpful. Enjoy!

Mavros Gatos’s picture

Thank you for help, but I can't create symbolic links.

cog.rusty’s picture

The first step to make a multisite work is to make all the domains and subdomains which you are going to use for the Drupsl sites to point to your Drupal installation directory:

http://www.site1.com ==> public_html
http://dev.site1.com ==> public_html
http://anothersite.com ==> public_html
(assuming that Drupal is installed in public_html)

This is absolutely necessary because if Drupal's index.php file is not accessed, Drupal will not receive any request for any site. If your hosting plan allows it you can do this straight from your cpanel. If you have access to Apache's configuration you can do it using vhosts. If not, you may need to use a trick with symlinks.

For example, if your cpanel allows only this:

http://www.site1.com ==> public_html (suppose Drupal is here)
http://dev.site1.com ==> public_html/dev
http://anothersite.com ==> public_html/anothersite.com

You will need to send the last 2 sites to Drupal as well:

// go to your web root
chdir /home/[blah]/public_html
// remove the subdomain's directory and replace it with a symlink leading back to Drupal
rm -r dev
ln -s . dev
// remove the other site's directory and replace it with a symlink leading back to Drupal
rm -r anothersite.com
ln -s . anothersite.com

Now Drupal receives all the requests for the different sites. It checks what was the requested URL (from a server variable) and it compares it to the names of the directories that you have created under sites/. If it finds a match, it retrieves the right database name from that site's settings.php file, and takes you there.

Note that you can't use .htaccess rewrites or redirects instead of symlinks, because those change the requested URL, and Drupal will see only the final URL.

Mavros Gatos’s picture

Now I have virtual hosting and Direct Admin panel.

Anonymous’s picture

Have you tried my steps? I am also working with virtual hosts. If you have further questions feel free to ask.

Mavros Gatos’s picture

I tried in general, but talking about your steps: when I add new domain, it points to newdomain.com/public_html, and, as I know, I can't change this.

cog.rusty’s picture

If each domain is in a different user account it is difficult to use it in a Drupal multisite.

Check if you can set up more domains on the same user account, which behave just like the subdomains.

Mavros Gatos’s picture

What do you mean by user accout?

If I understand right, domains are on the same account, as their paths are:

/home/account_name/domains/example1.com/public_html/
/home/account_name/domains/example2.com/public_html/

cog.rusty’s picture

Not necessarily. On a shared host that I am using I can host as many domains as I want on each user account, from the same control panel. They are calling them "domain pointers" but they are regular domains. So, I have something like this:

/home/myuseraccount/public_html
/home/myuseraccount/public_html/domain1.com
/home/myuseraccount/public_html/domain2.com

etc

And I can easily delete those directories and replace them with symlinks pointing to wherever.

Mavros Gatos’s picture

So, I will point subsite domain to main site domain and see what happens.

And I want to ask: there is tickbox "Create as an Alias". Should I tick it?

cog.rusty’s picture

You said you are using Directadmin? Yes I remember that tickbox. It has been a long time since I saw Directadmin, but I think you need to tick that, to make the new domain name stay as it is, and not change to the destination domain name.

Mavros Gatos’s picture

There is one good result: now domain, that is supposed to be a subsite, is displaying content of main site (of public_html folder).
(Yes, it should be addon)

I tried to install subsite, but I get "Drupal already installed".

cog.rusty’s picture

So, the new URL reaches Drupal but it brings up the old site?

- Does it keep the new URL in the browser when that happens?
- Does the new URL match with a directory name under sites/, sites/example2.com, which contains a fresh settings.php file?

Mavros Gatos’s picture

> So, the new URL reaches Drupal but it brings up the old site?
Yes.
But, for example, when I change site name in subsite.com/settings.php, subsite's name also changes, so something works.

> Does it keep the new URL in the browser when that happens?
Yes, subsite.com (just an example name) keeps url and displays links (subsite.com/admin, subsite.com/node1, ...). But all this data, as well as user, are the same as in main site.

> Does the new URL match with a directory name under sites/, sites/example2.com, which contains a fresh settings.php file?
Yes

cog.rusty’s picture

But, for example, when I change site name in subsite.com/settings.php, subsite's name also changes, so something works.

Wait! Do you mean that it does read the new site's settings.php? Is it possible that you have left the $db_url of the main site's database inside the new settings.php file?

If it reads the name then probably it reads some database settings too.

Mavros Gatos’s picture

> Do you mean that it does read the new site's settings.php?
Exactly.

And yes, I have left $db_url ... line. Actually, I tried to delete it, but installation told me that site is already installed. Now I understand a problem: I should just add database prefix while installation.

So, I deleted $db_url ... line, and added prefix to database, and... oh my God! Subsite is working!

Mavros Gatos’s picture

.

Mavros Gatos’s picture

Thanks everyone! Especially cog.rusty for his patience and efforts. Unbelievable!

Multisite works. (Althought, I guess, it is a beginning of new nightmare headaches :-)

Bensbury’s picture

Hi,

I have a similar problem and I have been following the thread. Sadly the solution is not good for me.

I am running WAMP server on a local host.

In sites I have two folders:

drupal/sites/egeos
drupal/sites/test

egeos is the original single site and already has a database. (it used to be default)
test is the multi site I want to create.

Originally egeos settings were in default.
I copied them to the egeos folder to see if I could get the single site working and moved default somewhere else.

Now I understand it as this:

http://localhost/drupal/egeos --- Should go to the egeos site, which already works and has a database.

http://localhost/drupal/test --- Should go to the unmade test site and let me set up a new site in Drupal.

However........both these urls redirect to:

http://localhost/drupal/install.php?profile=default

If I choose to install it creates a new default folder in my sites directory.

So this is telling me that Drupal cannot find:

http://localhost/drupal/egeos or http://localhost/drupal/test

What url do I need or what do I need to do to make Drupal see my subsites and redirect to them?

The way I understand everything so far is that I shouldn't have to do anything.

Just make new site folders, and then put the name of the site into the url.
Drupal searches the site folder for files that resemble the url and then 'pow' it fixes onto the database registered in the settings file.

Somebody please educate me!

cog.rusty’s picture

By searching you will find many posts about how to do it with subdomains, but much fewer for subdirectory URLs.

To make a multisite with subdirectory URLs you need 2 things.

1) The URL http://localhost/drupal/egeos must *not* lead to the directory drupal/egeos. It must lead to the directory drupal. The same for all sites.

To achieve this you need to use:
- either a symlink (for windows XP, see junctions: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx): junction c:\[blah]\drupal\egeos c:\[blah]\drupal
- or Apache aliases in httpd.conf (Alias url_path directory_path), Alias /drupal/egeos c:/[blah]/drupal

2) If the URL of the site is http://localhost/drupal/egeos, then the correct name of the settings subdirectory is sites/localhost.drupal.egeos. If this name is wrong, Drupal will use the sites/default directory.

Bensbury’s picture

I keep reading things about rewrites in the .htaccess file.

Is this the same as symlinks or is it an alternative?

The site is running on WAMP which is emulating an apache server.

cog.rusty’s picture

No, rewrites are very different, because they change the request URL. They are not suitable for multisites.

With a symlink you can go to a different disk directory while the request URL remains the same. This is absolutely necessary for a multisite, because Drupal chooses the right site based on the request URL. (It compares the request URL with the names of the directories which you have created under sites/)

On Windows XP or 2000, the equivalent of symlink is junctions. On Vista or Server 2008 there is a mklink /J command.

Katharine_Gates’s picture

I know this is an very old thread, but I need help...

On my local I have a multisite installation -- one Drupal core, multiple databases. My directory structure is:

drupal/ contains core
drupal/sites/sitea contains its own modules, themes etc.
drupal/sites/siteb contains its own modules, themes etc.

This works AOK on my local. (I know know that I should have called siteb's directory drupal/sites/siteb.com/ but I didn't-- eeek.)

Now I want to move the local siteb onto a public server at siteb.com.

I did a fresh install of Drupal at my public server at webmasters.com. I put the siteb folder inside the "drupal/sites" folder and change the settings.php to connect to database.

It's connecting to the database OK, i.e. I'm getting the text and menus, BUT none of the contrib themes and modules are showing up. Only core modules and themes.

I have tried various versions of .htaccess, but no joy. Is the problem that I did not call siteb's directory on my local siteb.com? Any way to fix this?

Is it an httpd.conf setting issue? I have one of those files somewhere that I edited when I created my multisite install in the first place.

THANK YOU!

--Katharine