Running multiple sites off a single drupal codebase was my dream ever since I started experimenting with drupal six months ago. Despite the excellent features of drupal, most of its features are unfortunately confined to a choice group of geeks, as the documentation is best understood by the seasoned veterans.

The drupal install.txt about multisite is no exception. It misses out several steps thinking it as second nature for every user. However, the forums, though sometimes confusing, are of great help, and with the help of the forum topics and a few external resources, I managed to have my two sites and two subdomains up and running.

My environment

- shared hosting with cPanel, fantastico, NO shell access (and the host refused to create symlinks!).
- I was already running a fully-functional drupal installation at the location http://domainname1.tld. I had a few modules and themes in the "default" folder.

My knowledge

- not much knowledge with scripting, PHP etc.

What follows are the comprehensive list of steps I followed, and right, wrong, or different, it works! I will spare you the fine details, as I assume you are used to computers for a while..

Multisites with an additional parked domain

  • Using PHP MySQL or any other database application, create a database by the name "domain2"
  • Grant full privileges to the database to the default user
  • Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file ("database.sql").
  • Using cPanel or ftp, create a sub-directory in the "/sites" directory called "domain2.com"
  • Copy the /sites/default/settings.php to the new directory /sites/domain2.com/settings.php
  • Make changes to the following line in the new settings.php file
    $db_url = 'mysql://db-username:db-password@localhost/new-db-name';
  • Create a symlink from the new location to the main site, using the command (for example):
    ln -s /home/username/public_html/
    /home/username/public_html/domainname2

    Here, I am assuming your webhost has parked your new domain at "/domainname2" folder of your main account. In this example, the url http://domainname2.tld should resolve to the physical folder /home/username/public_html/domainname2 on your server (or shared server).

    If you don't have shell access and your webhost does not support creating symlinks, try out the symlink() function in php. Here is a step by step guide to using symlink function if you dont have shell access. Note that for this to work, it is necessary to delete the physical folder "/home/username/public_html/domainname2" from your web server, as the link created by symlink() is only symbolic and not actual. The article explains that in detail.

  • Now access your new domain name at the address http://domainname.tld
  • Create your first user account, which should be the admin user.

Multisites with a subdomain

This is very similar to the above, but I am repeating the steps just to be sure..

  • Using PHP MySQL or any other database application, create a database by the name "subdomain"
  • Grant full privileges to the database to the default user
  • Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file ("database.sql").
  • Using cPanel or ftp, create a sub-directory in the "/sites" directory called "subdomain.domainname.tld"
  • Copy the /sites/default/settings.php to the new directory /sites/domain2.com/settings.php
  • Make changes to the following line in the new settings.php file
    $db_url = 'mysql://db-username:db-password@localhost/new-db-name';
  • Create a symlink from the new location to the main site, using the command (for example):
    ln -s /home/username/public_html/
    /home/username/public_html/subdomain

    Here, I am assuming your webhost has redirected your subdomain to your "/subdomain" folder of your main account. In this example, the url http://subdomain.domainname.tld should resolve to the physical folder /home/username/public_html/subdomain on your server (or shared server).

    If you don't have shell access and your webhost does not support creating symlinks, try out the symlink() function in php. Here is a step by step guide to using symlink function if you dont have shell access. Note that for this to work, it is necessary to delete the physical folder "/home/username/public_html/domainname2" from your web server, as the link created by symlink() is only symbolic and not actual. The article explains that in detail.

  • Now access your new subdomain name at the address http://subdomain.domainname.tld
  • Create your first user account, which should be the admin user!

The above procedure was tested with 4.6 and 4.7. I have no clue about 5.0 RC. Any ideas?

Comments

astra’s picture

I've experience to create multisites using this way. It's really simple and effective.

BTW, for those added modules that expected to be shared by the multisites, where should the modules be placed if I don't like them together with the core modules?

cog.rusty’s picture

The modules can be placed under the settings directory of each site (where the settings.php file is). Then they will be visible only by one site.

That is:
/sites/site1.tld/modules
/sites/site1.tld/themes
/sites/site2.tld/modules
/sites/site2.tld/themes

This is possible in both Drupal 4.7 and Drupal 5.
Additionally, in Drupal 5 you can place your shared contributed modules and themes under /sites/all/modules and /sites/all/themes and they will be visible by all sites.

AstaC’s picture

Symlinks is something new to me. What do you more exactly do with the symlink?

cog.rusty’s picture

A symlink (symbolic link) in unix-like systems is something similar to a Windows shortcut. It is a special file which lead to another specified file or directory.

Notice the example above:

ln -s /home/username/public_html /home/username/public_html/subdomain

This creates a file called "subdomain" which takes the place of the deleted directory "subdomain". When you try to go there, you find yourself in "public_html" (where Drupal is installed).

Windows shortcuts do not have exactly the same functionality, so there is a utility program called "junction" which behaves in the same way as symlinks.

-------

Someone here asked me what is the difference between a symlink and a Windows shortcut.

Suppose we have a directory /home/aaa/bbb/ccc, and ccc contains some files.
We are in /home, we create a symlink ddd leading to ccc, and then we go to ddd.

ln -s aaa/bbb/ccc ddd
cd ddd

We look around and we see the files contained in ccc. So far so good. But where are we?
- If it was a Windows shortcut we would be in /home/aaa/bbb/ccc. If we step back we go to bbb.
- But with a symlink we are in /home/ddd. If we step back we go to /home.

AstaC’s picture

but I still don't get it. I now understand how it works. But what kind of a file do you create? Is the symlink the name of an empty file where the only important thing is the name of the file? And do you put it where the directory "subdomain" should have been?

Thank's for taking time explaining to me by the way.

cog.rusty’s picture

Yes, it is something like an empty file with two important properties: Its name and where it leads (or what it represents).

And yes, you put it where the directory "subdomain" should have been (after deleting the directory if it was there).

AstaC’s picture

I believe I was a bit confused there. That command is to be done in the database isn't it?
If I want to do a symlink in php instead, like in the link above, then I am supposed to do it in a .txt - file. But what should that file be called an where should it be put. The site in the link only gives me the content of the file, it doesn't say exactly what to do with it ( I tried to register on the site to ask the question there but it didn't work).
Shortly;
If i do the symlink in PHP what do I call the file?
And when it says put the file in the root is root=directory where Drupalinstallation is placed?

cog.rusty’s picture

Not in the database. It is a command which you type in a linux command console, if you have shell access to the server's file system. That small php script is an alternative way to do it, by making the web server enter the command for you.

To tell you exactly what it should contain and where to upload it, I must know:
- the directory path of your web root (where you go when you type www.example.com)
- the directory path where you have uploaded Drupal (straight into the webroot directory, or in a /drupal subdirectory?)
- the web path (or the subdomain) which you want to use for your second site

AstaC’s picture

Sorry for being a nuisance. I have a domain
example.com
There I have created subdomains.
example1.com
example2.com
example3.com
I have an original Drupal installation 4.6 in example.com and don't want to touch it right now.
So I have installed Drupal 5.0 beta 2 in example1.com.
Now I want to create a multisite where I can access example2.com and example3.com via my installation in example1.com. I understand the settings.php part but I do not understand the symlinks-part.

cog.rusty’s picture

Oh, so you have full domain names and not just subdomains.

Then other solutions may be more suitable than symlinks. For example, not to create domain2 and domain3 but make them CNAMES (aliases) for domain1 so that all three use the same web root directory. If you can do this, then nothing else is needed. Drupal would take over and serve three sites.

Anyway, here is what you would do with symlinks (if there is nothing in your host's setup to forbid it):
- example1 uses the web root directory webroot1
- example2 uses the web root directory webroot2
- example3 uses the web root directory webroot3
You want example2 and example3 to use also the webroot1 directory.

Let's assume that they are three parallel directories under your main webroot directory (is it so?). If the three directories are parallel you can do the following.

1. Create a text file containing:

symlink(".", "../webroot2");
symlink(".", "../webroot3");
print "Done";

These commands mean: Create a symlink pointing here (the single dot), place it one step back (the double dot) and name it webroot2 (or 3).

2. Name this text file 'linkthem.php' or anything you want and upload it to the webroot1 directory.

3. Step back one directory and delete or rename the webroot2 and webroot3 directories (using FTP), so that symlinks can take their place.

4. Go one more step back using FTP, behind the parent directory of the three parallel directories, and make it "writable by all" for a minute (right click with your FTP program, set its permissions to 777). This is needed because otherwise your php script is not allowed to create files in there.

5. Using your browser, go to http://example1.com/linkthem.php. Then the script will run. If it is successful you won't see any error messages but only "Done". Refresh the view of your FTP program to see if the webroot2 and webroot3 symlinks are in place.

6, A little housekeeping: Put the parent directory's permissions back to 755 (or whatever it was) and delete or hide the "linkthem.php" file.

The rest is up to Drupal.

AstaC’s picture

Thank you very much that was a very good explanation. Now it is up too me to try it! And yes they are parallel directories.
I want to make a testsite before I start trying to do the real site
Thank's again!

AstaC’s picture

Please answer another question for me.
How do I delete a symlink?
I did something terribly wrong. I tried to create a symlink and now my whole domain is suddenly under the symlink. And I do not know how to undo it?? And without loosing my whole site?
My symlink mirrors the whole site - and I now cannot delete the symlink because if I do so i delete the whole site.

cog.rusty’s picture

You can delete a symlink without fear, like any other file. The directory where it points will not be affected.

Just make sure that you are deleting a symlink and not a real directory.

If the server does not allow you to delete it with FTP (because it was created by a script and now it is owned by the webserver), then use a script again to delete it.

If your directory structure was exactly like my example, you would create this text file to delete the symlinks:

unlink("../webroot2");
unlink("../webroot3");
print "Done";

(If they are real directories these php statements will refuse to delete them anyway).

You would name this "delthem.php", you would upload it to "webroot1", you would unprotect (777) the parent directory of the three parallel directories, and you would run the script by going to http://example1.com/delthem.php with your browser.

It would have been easier if you gave your exact directory structure and "which is where"...

AstaC’s picture

I probably haven't enough skill to try these things. Just thought I'd be smart and rebuild my sites since I want to change them and at the samt time upgrade to 5.0 when my test worked out.
I thought I explained it correctly but now I se I didn't. Just to show anyway. When I look in my FTP window it looks like this.

12.23.345.456
|
|- mysite.org
|
|- blogs.mysite.org
|
|- food.mysite.org
|
|- food1.mysite.org
|
|- food3.mysite.org
|
|- food4.mysite.org

Mysite.org is my domainname. Mysite.org and blogs.mysite.orgs are two running Drupalsites in 4.6.6.
The four food.mysite.orgs is my testsites where I want to learn Drupal 5.0 and where I wanted to try multisites. But I'm starting to think this is more than I can cope. I think I've read almost everything about multisites here and the only thing I really get is that I'm supposed to create a folder in settings with a settings.php in. Everything else is mere gibberish to me. I just don't get it.

cog.rusty’s picture

As you said, you are supposed to create folders under /sites with the names of your sites, each containing a settings.php file for a site. This is how Drupal will know to choose and bring up the right site that the user asked.

But to do this, Drupal first must be asked. This is why all user requests for different sites must go where Drupal is installed.

I think that you almost made it work.

You went to "http://food1.mysite.org" and you saw "mysite.org", ok?
This means that the symlink worked, but you also needed under "mysite.org" a "/sites/food1.mysite.org/setings.php" file to make Drupal choose the correct sub-site, "food1".

AstaC’s picture

What I did was when I tried to create the symlink I forgot to write .org. I wrote food1.mysite. And in my FTP-window I suddenly have something that looks like a folder and is called food1.mysite. And in that folder the whole 12.23.345.456 and all the sites is mirrored.

And the code I ran was

<?php
symlink(".", "../food1.mysite");
print "Done";
?>

And it looks like this

12.23.345.456
|
|- mysite.org
|
|- blogs.mysite.org
|
|- food.mysite.org
|
|- food1.mysite- ---------| 12.23.345.456 etc
|
|- food1.mysite.org
|
|- food3.mysite.org
|
|- food4.mysite.org

cog.rusty’s picture

It is just a symlink. You can delete it.

But be careful where you upload the script, because this symlink shouldn't point to 12.23.345.456. It should only point to one site where you have Drupal installed. There must be another mistake.

cog.rusty’s picture

Let me repeat briefly what you need to do for these sub-sites.

1. Create the database for food.mysite.org and install Drupal 5.

2. Rename food1.mysite.org to old-food1.mysite.org to make space for the symlinks.
Do the same with old-food2, old-food3 and old-food4.

3. Create the symlinks with a script containing:

symlink(".", "../food1.mysite.org");
symlink(".", "../food2.mysite.org");
symlink(".", "../food3.mysite.org");
symlink(".", "../food4.mysite.org");
print "Done";

I won't repeat the details here... upload the script and run it in food.mysite.org to create the 4 symlinks for the 4 sites. Now, all sites will lead to to food.mysite.org (don't be surprised) and it is time to make Drupal choose between them:

4. Under "food.mysite.org/sites" create the subdirectories:

food.mysite.org/sites/food1.mysite.org
food.mysite.org/sites/food2.mysite.org
food.mysite.org/sites/food3.mysite.org
food.mysite.org/sites/food4.mysite.org

In each subdirectory, upload a fresh settings.php file.

5. Now you are ready. When you go to one of these sites, for example, http://food1.mysite.org, Drupal will ask you for a database and prefix and will start a new installation.

AstaC’s picture

I'll try it again when I have the nerve :)
I put the script in the root of food.mysite.org

You are a really patient person.

AstaC’s picture

Something doesn't work. Now I have created and uncreated symlinks. But the symlinks do not point at food.mysite.org they still point at 12.34.56. etc. When I write the adress in the browser I se all my folders = my different domain-folders.

cog.rusty’s picture

This is a mystery to me too.

I did some experiments with using symlinks across different domains and I found that FTP (Filezilla) gives strange results when I click on the symlink.

However linux shell commands seemed to behave correctly with the symlink, so I went on and created the subdirectory under /sites anyway, then I went to the secondary site with the browser and everything worked.

So, it is possible that only FTP has this problem with symlinks and you can ignore that puzzle and go straight to the real directory to set up all the sites.

David Field’s picture

I liked the code

symlink(".", "../webroot2");
symlink(".", "../webroot3");
print "Done";

which cog.rusty suggests

I adapted the code to replace the ".." double dot in the code with a "." single dot. This then suited my directory structure which has my main site at top level in public_html (it's called www.stride4.net) and my addon sites in the lower down folder of public_html/sites
Although ANhosting, my hosting providers, granted me shell access for creating symlinks, I found that it was easy enough just running the PHP code without going into shell access. I did not manage to set up multisites by just using Cpanel without using symlinks as suggested as being possible in some posts in this thread.

One thing that caught me out is as follows:
Say your new domain is called mynewsite.com. When you use Cpanel (using the addon domains menu) to create a folder for this new domain under public_html it will let you call it "mynewsite" but it will not let you call it "my newsite.com" This is not a problem though. You let Cpanel proceed to create the folder. You then delete the folder and create the symlink in it's place also calling it "mynewsite"
However, remember when you create the drupal subdirectory under public_html/sites this time it IS called "mynewsite.com" with the ".com" extension. NB Also do not make the mistake of putting it in public_html/sites/all. And remember to finally run install.php as your last step.

David Field

Imago’s picture

"I did not manage to set up multisites by just using Cpanel without using symlinks as suggested as being possible in some posts in this thread"

That's the esaiest way to set up a new site in the chain.

If new domain - use the addon domain function (create foo.com in folder foo)
If subdomain - add new subdomain (foo in folder foo)

Then go ftp or ssh and delete the new folder /foo in the root and execute

ln -s /home/account/public_html/ /home/account/public_html/foo

and you are ready to install

David Field’s picture

I think its one of those 'its easy when you know how things'
The Linux directory structure is all new stuff to me.

For the code ....
ln -s /home/account/public_html/ /home/account/public_html/foo and the other similar example in this thread,
I had assumed that the 'home' word has to be replaced with something else specific to my server directory structure. I now since realize you literally type 'home'. Simple.
Thanks.

kding’s picture

cog.rusty. I have been asking you questions these past 2-3 days. Thank you for your willingness to reply. Yesterday I followed your 6 steps in your "Oh, so you have full domain" (i like this subject line) because I was trying to install a multisite in a new domain I bought. I went through your six steps with no problem (I mean at least I did not see error messages). Now, your last line after the step #6 is "The rest is up to Drupal". In conjunction with other posts in this thread, I believe what you mean is similar to "browsing your second site and see what happens". Am I right?

My main site is http://tech4he.org
My 2nd site is http://tech4he.org/epi

If you go to the second site you will see it is exactly the same as what you see at the main site. I tried to create new menu items and add new nodes at both sites but I saw the "same site" at both sites (of course, I think, because everything goes to the same database). So, does this mean something wrong in my 6-step installation? Or I did not do right at "The rest is up to drupal"?

I feel I am making progress but not quite enough yet. Thanks again!

cog.rusty’s picture

You should be almost there. The first part was to make all your sites' URLs to lead where you have installed Drupal (either using symlinks or using your cpanel, or in another way, it doesn't matter).

Now when you visit any of the sites, Drupal takes over. It examines the URL which the browser asked, and compares it with the names of the directories under /sites.
- If it finds a matching directory name, it looks inside for a settings.php specifying the database of that site and brings up that site (or installs a new one if it didn't exist).
- If it finds no matching directory name, it uses the /sites/default directory.

So, suppose that you have your main site's settings.php file (which contains its database info) in /sites/defauls.
- Create a new directory under /sites, and name it tech4he.org.epi (i.e. sites/tech4he.org.epi - notice the last dot).
- Then visit http://tech4he.org/epi and the new directory will be used for the new site's settings.

kding’s picture

So, suppose that you have your main site's settings.php file (which contains its database info) in /sites/defauls.
- Create a new directory under /sites, and name it tech4he.org.epi (i.e. sites/tech4he.org.epi - notice the last dot).
- Then visit http://tech4he.org/epi and the new directory will be used for the new site's settings.

When I browse through the main and second sites they look the same. Should I put anything under /sites/tech4he.org.epi? Thank you. I am getting excited.

cog.rusty’s picture

I had to go and try it myself, because there has been a small change in Drupal 6.

1. Copy sites/default.settings.php to sites/tech4he.org.epi/settings.php (copy and rename).
2. Edit sites/tech4he.org.epi/settings.php, find the $db_url and $db_prefix lines, and comment them out by putting a # in front.
3. Browse to http://tech4he.org/epi and the installation sript will start.

Alternatively:
2. Instead of commenting out the 2 lines, fill-in the correct values for the new site.
3. Browse to http://tech4he.org/epi/install.php (in this case it is needed), and the installation script will proceed without asking you about the database.

If you need to go back to fix something, note that after installation Drupal makes the settings.php file and the tech4he.org.epi directory write-protected (permissions 444 and 555 respectively), and you may need to chmod them to 644 and 755 to make any changes.

kding’s picture

I want to thank cos.rusty for being so patient with me and helpful in guiding me through my multisite installation process. From my own experience I am going to add more steps after cos.rusty's six steps in his wonderful post "Oh, so you have full domain". I use my own case as an example. (I have drupal 6.2 installed at my root, or tech4he.org. I want to have a second site at tech4he.org/epi, which is NOT a subdomain. After cos.rusty's 6...)

7. use FTP to create a new directory: site/tech4he.org.epi (the new directory name is tech4he.org.epi).

8. found the file at site/defualt/default.setting.php. Edit it by commenting out the two lines in the file just like this:

#$db_url = 'mysql://username:password@localhost/databasename';
#$db_prefix = '';

9. do nothing else but change the file name from default.setting.php to setting.php

10. upload the setting.php to site/tech4he.org.epi fold

11. change setting.php's permission to 777

12. Browse to http://tech4he.org/epi

13. (dang dang dang da...) The page you see now is the installation script page asking you to enter database installation information.

14. by this time I realized I need to set up a database first. So I went to my cpanel to creat a database.

15. I went back to #13 to finish the database set up process. By the end It said to change setting.php permission back to 755.

16. I did it, and then

17. browse to http://tech4he.org/epi again. A new site was born.

That is my initial experimentation. I still have a lot to test and to learn. But at least I have gone thus far. Thanks again.

kding’s picture

I used this following php to creat symlink the way cos.rusty's steps said:

symlink(".", "epi");
print "Done";

When browsed tech4he.org/linkthem.php I saw nothing but "Done". Then I browsed tech4he.org/epi, and saw the same screen as I had at root url. I started the above step 7 from there.

cog.rusty’s picture

By the way, in #14, creating a new database was optional. You could have used the same database for convenience, with a different prefix for the tables, for example $db_prefix="epi_";

node table
user table
....
epi_node table
epi_user table
...
etc

kding’s picture

I figured it out later, and used prefix method. However, I don't know why prefix_ is better or worse than seperate database. How does this affect: speed, moving a drupal site, traffic count, etc.

cog.rusty’s picture

From what I have heard (can't judge), separate databases are generally better, except if (a) you don't have them or (b) you want to combine users/content/settings from different sites.

kding’s picture

How to combine settings, themes, and modules? I have three sites with three different prefix in the same database.

cog.rusty’s picture

It is a very complicated subject. Many people want to have the same users on all sites, and a few want to share some content as well. This is done by sharing some of the database tables between sites, but there are many pitfalls. See for example http://drupal.org/node/147828

kding’s picture

Yeah, I don't want to go there.
When I change something like permission, content types, etc. for one site, are these changes saved in database tables? If so, can I simply export a few of relevant tables from one site and import them into another site to make the same changes? (I guess separate database is better in this scenario).

cog.rusty’s picture

Everything is in the database, and there are modules for exporting-importing content, categories and some other things from tables. But this needs to be done carefully by a program using Drupal's API because, for example, a particular user may have a different ID in the databases of two sites, or two different pieces of content may happen to have the same numeric ID in the two databases... this kind of thing.

The same pitfalls that I was talking about regarding shared tables.

kding’s picture

I will experiment a little bit. sounds scary though.
thank you!

hbryan’s picture

I understand what to type in place of "username" and "public_html" in my text file but what goes in place of "home"?

ln -s /home/username/public_html /home/username/public_html/subdomain

I guess for subdomain I should type "subdomain.domain.net"?

Running 4.7.

cog.rusty’s picture

"subdomain" is the name of the real directory which the subdomain expected to find there (which normally would contain the subdomain's files).

Instead of a directory, it will find a symlink with the same name, which will lead back to public_html.

hbryan’s picture

Thank you. I guess I did it right but it wasn't actually what I needed. :(

I wanted art.domain.net to resolve to domain.net/art but ended up with domain.net/art resolving to domain.net.

Meanwhile I asked my host for advice and they assert that symlinks won't even do what I am looking for. (they're not very familiar with Drupal)

Should the settings.php file in public_html/art/sites/all be the same as the one in sites/art.domain.net?

cog.rusty’s picture

You wrote:

I wanted art.domain.net to resolve to domain.net/art but ended up with domain.net/art resolving to domain.net.

Right, but I don't understand what you are trying to do. Didn't art.domain.net already point to the domain.net/art directory? The only reason to do the above is if you want to use a Drupal installation which is in public.html and not in public.htm/art.

If you have Drupal installed in /public_html/art and you have a subdomain which already maps there, then you don't need any symlinks. In that case, only one settings.php file in public_html/art/sites/art.domain.net is enough

(and not even that is necessary -- if you have only one Drupal site, then public_html/art/sites/default would do the job as well).

Or did I get your setup wrong?

hbryan’s picture

I have never on any try gotten art.domain.net to be anything but be a "page not found".

I already have a site, domain.net. I need a second site, art.domain.net.

Toward this end, I followed the instructions above, for multisite with a subdomain. After following the instructions I didn't get a new/second site on art.domain.net, I got domain.net duplicated/mirrored at domain.net/art.

Those original instructions didn't specify the second Drupal install in the folder in public_html, I read that further down the page. I need the second site to look and feel different from the main site, for this reason I guessed that (maybe) this "second drupal instance" instruction applied to my circumstance.

If you have Drupal installed in /public_html/art and you have a subdomain which already maps there, then you don't need any symlinks. In that case, only one settings.php file in public_html/art/sites/art.domain.net is enough

The subdomain art.domain.net is not mapped anywhere. It has never worked.

(Hmmm .. maybe I need to register the subdomain and have it parked where I need it???)

If I'm not using a second instance of drupal, what the heck should display when the browser calls up art.domain.net? If it is supposed to just mirror the domain, then that totally defeats the purpose for me.

What goes in that public_html/art if not a second instance of drupal?

cog.rusty’s picture

More questions...

1. When you created your art.domain.net subdomain in your control panel, you were supposed to get a directory where you would put its files (usually, but not necessarily, public_html/art). If you didn't notice that directory, can you delete and then create again the subdomain and this time watch closely for that associated directory name?

2. Is your existing site (at domain.net) a Drupal site? (I mean did you already have a Drupal installation in public_html or is that a different kind of site?) If a Drupal installation already exists, you will reuse it with a symlink. If not, you will just install Drupal in the subdomain's directory.

hbryan’s picture

1. I do not seem to have the ability through my host control panel to create a subdomain. I actually thought that creating the symlink was sort of the same as creating the subdomain .. :O

I guess I would need to ask my host to do this (create the subdomain)?

2. Our existing site is a drupal site.

Are symlinks only needed for multisite with a single drupal instance?

Or .. if my host creates my subdomain do I still need a symlink?

Thank you for your patience CogRusty. You're obviously a saint. :)

cog.rusty’s picture

Heh, was I so obvious :)

Subdomains and domains are Web things. Symlinks are just file system things, somehow similar to Windows shortcuts. Big difference.

If you can't create a subdomain yourself using some kind of control panel, then do ask your host.

- The most convenient would be a http://art.domain.net subdomain pointing to the same public_html directory, same as your main site. Then you would not need a symlink for your second site.

- The most likely case is a http://art.domain.net subdomain pointing to a public_html/art directory. In that case you would do what you tried before -- delete the art directory and replace it with a symlink pointing back.

- A third case, if you can't have a subdomain, is to just use an URL with a subdirectory, such as http://www.domain.com/art. Again you will need a symlink. There won't be a real "art" directory, just an "art" symlink pointing back.

In all cases, the user will land into public_html, where Drupal will ask "What was the user's request? Was it www.domain.net or art.domain.net or what?" and then it will check the names of the directories under /public_html/sites to make the best match and present the right site.

hbryan’s picture

Thank you!

It's in my host's hands for now, I'll wait to hear back if we can get our subdomain.

Peculiar_One’s picture

Because I'm confused. I've been trying to follow the various instructions in this thread and elsewhere but haven't had any luck no matter what I do.

If you have Drupal installed in /public_html/art and you have a subdomain which already maps there, then you don't need any symlinks. In that case, only one settings.php file in public_html/art/sites/art.domain.net is enough

These are the steps I've taken:

    1. Fresh install of Drupal 5.1 in public_html
    2. Created new database and user will full privileges
    3. Via cPanel, created sub-directory in /sites/myhusbandssite.domainname.net
    4. Copied settings.php from sites/default to sites/myhusbandssite.domainname.net

This is what I'd like to do: Use current Drupal install in domain root to run three subdomains--

    mysite.domainname.net
    myhusbandssite.domainname.net
    mydaughterssite.domainname.net

--so that, for example, accessing the URL http://myhusbandssite.domainname.net directs to a Drupal instance on his site that can have whatever templates and modules he wants suitable to his needs for his site and ditto all that for my daughter and myself.

What I'm confused about:

    1. Do these subdomains need created first via cPanel in addition to creating sub-directories of the same names in the sites directory or not?
    2. Do I need to implement symbolic links to achieve this?
    3. Am I understanding correctly that it is no longer necessary to alter the base_url and database data in the copied settings.php file?

Thanks very much for any help.

vm’s picture

1. Do these subdomains need created first via cPanel in addition to creating sub-directories of the same names in the sites directory or not?

so long as they are created doesn't matter whether they come first or last. With some hosts you can point the subdomain at the maindomain during the setup of the subdomain. Other hosts create the subdomain and automatically point to it, which you can then change in your host panel. The thing I see most people do incorrectly most often, is they point the subdomain to the sites/subdomain.maindomain.com folder. This is incorrect. teh subdomain should point to the same folder that Drupals index.php is located in.

2. Do I need to implement symbolic links to achieve this?

yes, the subdomain that is created needs to point to the main domain. When a user calls subdomain.maindomain.com Drupal will then search the sites folder for a match based on that subdomain.maindomain.com. If drupal finds a fresh settings.php, then drupal will attempt to install. if drupal finds a settings.php that already has a $db_url in it (inserted upon installation), Drupal will then run normally.

3. Am I understanding correctly that it is no longer necessary to alter the base_url and database data in the copied settings.php file?

Drupal expects one of 2 things. A fresh settings.php file without a $db_url for installation so that it can install the next site of the multisite or a $db_url that is already filled in and pointing to an active DB for the site to run.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

Peculiar_One’s picture

...With some hosts you can point the subdomain at the maindomain during the setup of the subdomain. Other hosts create the subdomain and automatically point to it, which you can then change in your host panel. The thing I see most people do incorrectly most often, is they point the subdomain to the sites/subdomain.maindomain.com folder. This is incorrect. teh subdomain should point to the same folder that Drupals index.php is located in.

Just to clarify if I may...when you speak of the subdomain "pointing to" a location, are you speaking of achieving this using a symbolic link or using the subdomain redirection form in the subdomains section of cPanel?

... If drupal finds a fresh settings.php, then drupal will attempt to install. if drupal finds a settings.php that already has a $db_url in it (inserted upon installation), Drupal will then run normally.

Drupal expects one of 2 things. A fresh settings.php file without a $db_url for installation so that it can install the next site of the multisite or a $db_url that is already filled in and pointing to an active DB for the site to run.

Presently, if Drupal were to read the settings.php file I copied into sites/myhusbandssite.domainname.net the $db_url listed there is the database created during the original install, so that is incorrect and I need to change it to the database *I* created (ie, $db_url = 'mysql://domainname_husbandsdb:husbandsdb password@localhost/domainname_husbandsdb';), correct?

The symbolic links thing I will have to look into a little more. I'm familiar with them by name and general function, but have never had the need to create any. I'm on a GNU/Linux box but I haven't done enough command line stuff to really know what I'm doing yet and I'm pretty sure I have shell access to my server but not quite sure how to go about all that either, so as I said, I will have to do some more reading.

Thanks for helping get me going in the right direction though! Much appreciated. :)

vm’s picture

when you speak of the subdomain "pointing to" a location, are you speaking of achieving this using a symbolic link or using the subdomain redirection form in the subdomains section of cPanel?

either method works. Essentially cPanel is creating the symbolic link for you and doing it through cPanel is fine. I don't do it through the command line I use my hosts panel. (not CPanel but same premise)

Presently, if Drupal were to read the settings.php file I copied into sites/myhusbandssite.domainname.net the $db_url listed there is the database created during the original install, so that is incorrect

yes that is incorrect. you want a brand-spanking-new settings.php from a fresh download or an archived download you have on your local machine.

I need to change it to the database *I* created (ie, $db_url = 'mysql://domainname_husbandsdb:husbandsdb password@localhost/domainname_husbandsdb';), correct?

nope, you want a fresh settings.php untouched by you, or by drupal. just like you had when you downloaded drupal orginally for the first site.

by uploading a fresh settings.php drupal will find it and run install.php again. You will see the same screens you saw when you installed drupal the first time. you will enter your DB location DB username DB password and drupal will add it to settings.php as it orginally did. This time though you will enter the information for the 2nd DB (be it your husband or your daughter).

If you are running all three websites off of the same DB you will have to expand the collapsed advanced settinsg menu during install and set a DB prefix. if you are using multiple DB's (one for each site) then you don't have to worry about prefixes.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

Peculiar_One’s picture

either method works. Essentially cPanel is creating the symbolic link for you and doing it through cPanel is fine. I don't do it through the command line I use my hosts panel. (not CPanel but same premise)

That little tidbit just made my day! :) Thank you very much!

I've just given it a whirl and it looks like progress has been made, however one thing is puzzling me, or rather--not working as I anticipated--and that is when I type the URL to my husband's site in Firefox instead of showing http://myhusbandssite.domainname.net/ in the address bar (as I was hoping it would), it jumps to and/or shows http://domainname.net/.

Of course, I feel like a complete idiot questioning this since I know full well that I just went in cPanel and instructed it to do precisely that, but then again, I suspect I've still not got something right. Admittedly, I am still slightly perplexed about what the $db_url should read. By copying the settings.php file from the default directory it *should* be about as brand-spanking-new as I know how to get it as no alterations were made to the original Drupal install--I've not so much as even ran the initial cron job to make the pink status report box go away. I installed it and immediately began looking into how to set it up for multi-site without adjusting any settings or adding anything at all. But the copy of the settings.php file from the default directory names the database Drupal created during the original install. Can I just delete the rest of the line of code behind $db_url in the settings.php file in sites/myhusbandssite.domainname.net, save it and try accessing it again with crossed fingers and toes?

by uploading a fresh settings.php drupal will find it and run install.php again. You will see the same screens you saw when you installed drupal the first time. you will enter your DB location DB username DB password and drupal will add it to settings.php as it orginally did. This time though you will enter the information for the 2nd DB (be it your husband or your daughter).

Yeah, see, I'm not getting any of this. I used Fantastico to put the original install in, which I wouldn't think would matter if Drupal is being told to read/run the install.php script again but apparently that message isn't getting through. If you know why and would be so kind as to tell me, I'll nominate you for sainthood, too. ;)

vm’s picture

now you just added a variable that I can't help with. I don't use nor have I ever used fantastico to install Drupal.

Personally, I'd scrap the fantastico install and work with a "normal" download that hasn't been altered by a 3rd party. This way you are always on same page with most of the people here in the support forums. Lastly, If that fantasico install is using any version of Drupal lower than Drupal 5.3 which was just recently released, than you are running an insecure version of Drupal. 5.3 includes patches to secure Drupal from hackers and fix some bugs that were found. AS of Drupal 5.x Drupal is no harder to install on your own using a download from drupal.org than it is to install using fantastico. IMO.

That aside, I mistakenly gave you incorrect advice. A subdomain redirect isn't what you want to do. This is why you are having trouble getting the install and the proper addresss to show in the browser.
what needs to be done is the 'document root' needs to be changed. In my host panel this is in the same menu as sub domain redirect, which is why I gave that advice incorrectly. Your host should be able to do this for you as well.

Just explain to them that you want your subdomains document root to be your main domain. Provided you can't find a way to do it in your hosts panel.

some of the conflict in advice between what I'm telling you to do and what the origainl thread is telling you to do is simply because the thread was based on 4.7 which did not have an auto installer built into Drupal that required a settings.php to be fresh.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

Peculiar_One’s picture

Personally, I'd scrap the fantastico install and work with a "normal" download that hasn't been altered by a 3rd party. This way you are always on same page with most of the people here in the support forums. Lastly, If that fantasico install is using any version of Drupal lower than Drupal 5.3 which was just recently released, than you are running an insecure version of Drupal. 5.3 includes patches to secure Drupal from hackers and fix some bugs that were found

Good advice, thanks--I've done just as you recommended and now have that brand-spanking-new settings.php file I needed. It's amazing the difference a few extra ounces of information can make. :)

Just explain to them that you want your subdomains document root to be your main domain. Provided you can't find a way to do it in your hosts panel.

If you're feeling exceptionally patient and have the time, I'm still not grasping this concept. If my subdomain's document root is the same as my main domain's document root wouldn't that essentially be what I had going on with the redirect? Either way, I can't see anywhere in cPanel where I can do this so I have made an inquiry at my host's forum.

Thank you for all of your help, though! By the way, I like your signature. :)

vm’s picture

If my subdomain's document root is the same as my main domain's document root wouldn't that essentially be what I had going on with the redirect?

no. A redirect redirects traffic in total. a change of the doc root is essentially a symlink.
a user goes to subdomain.yourdomain.com
inside that folder is s small file that pushes users to your domain.com (without changing the address)
drupal then handles scanning the sites. folder for a match based on the domain the user is coming from.

you may want to follow this thread : http://drupal.org/node/123974

from what I'm reading in there, there is something in cPanel called a subdomain manager, where you can point your subdirectory to your main directory. There is also a small script that can be run to create a symlink.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

Peculiar_One’s picture

I think I understand it now. Thanks, too, for the link. Going to check that out stat.

fiLi’s picture

Checkout the following solution - "PHPsh: Simple web based shell access to your server" on : http://www.psychogenic.com/en/products/PHPsh.php

It does what the page you linked to offers, only it doesn't limit the commands used and it gives you the server's response.
That would make this guide even easier. Thanks for writing it.

bb37’s picture

This looks like useful information, but I'm having trouble making it work.

I have shared hosting with cpanel access.

I have a domain, domain1.net, that points to my shared host site and that works great.

I have another domain, domain2.net, that also points to my shared host site.

I have gone through the steps of creating /sites/domain2.net/settings.php.

In cpanel, if I "park" domain2.net, then calls to that address display my domain1.net site. That's not what I want.

If I unpark domain2.net and, instead, configure it as an "add-on" domain, cpanel creates /public_html/domain2. I have tried calls to domain2.net both with /public_html/domain2 in place and without. In the first case, I get a 403 error. In the second case, I get a 500 error.

Also, when I try the symlink() php trick, I get the following response:

Warning: symlink() [function.symlink]: No such file or directory in /home/username/public_html/setsymlink.php on line 3

I like the "for dummies" approach because Drupal multisites have vexed me in the past. Does anybody have any additional help?

Bob...

cog.rusty’s picture

I guess "parking" means using a domain pointer, which won't work here as you already noticed (because it redirects the request to domain1.net).

Assuming domain1.net points to /public_html and that is where Drupal is installed:
- create an "add on domain" for domain2 as you did
- then delete (or rename) the domain2 directory (the one under public_html)
- create a /public_html/domain2 symlink in its place, which points back to /public_html.

To do this, your /public_html/setsymlink.php should contain symlink(".", "domain2"); and your public_html should be writable by all (777) when you run the script.

Then set up /sites/domain2.net/settings.php as you did.

bb37’s picture

Thanks for the quick reply.

I used cpanel to make domain2.net an "add-on" domain. And I edited my setsymlink.php file, which is located in /home/username/public_html, to read as follows:

<?php symlink(".", "domain2.net"); ?>

I changed the permissions on setsymlink.php and the /home/username/public_html directory to 777.

When I run setsymlink.php, I get a 500 error.

I'm sure there's something simple I'm missing.

Bob...

cog.rusty’s picture

When you create the domain2.net add-on domain, what directory does it create? Is it "/public_html/domain2", as you said in your first message, or is it a "/public_html/domain2.net" directory? The symlink should replace exactly that directory.

Max_Headroom’s picture

symlink(".", "domain2.net");

I changed the permissions on setsymlink.php and the /home/username/public_html directory to 777.

When I run setsymlink.php, I get a 500 error.

I'm jumping in here as it is similar to my problem. I get the 500 error when I chmod public_html to 777. If it is 755, then I can create a link...
but, it does not work. I read this thread and got all happy that I've found the solution, but I get "Server not found" error when I use my link.

My setup:
Using Cpanel. I have (a vanilla) Drupal 5.1 installed in public_html and I want to link a subdomain to it.
I have a php file in public_html with the following line:
symlink(".", "dev.mysite.com");

The link gets created. I see it with ftp. If I open the link in ftp I see a mirror of my public_html.
But if I run my subdomain (dev.mysite.com) URL in my browser, I get a "Server not found".
My main URL works fine (mysite.com).

I can link and unlink all over the place, but I can not get my link to start.
O, and I have /public_html/sites/dev.mysite.com/setting.php where I use the same database but with

 $db_prefix = array(
      'default'   => 'dev_',
      'users'     => 'shared_',
      'sessions'  => 'shared_',
      'role'      => 'shared_',
      'authmap'   => 'shared_',
      'sequences' => 'shared_',
    );

Am I missing something (besides my mind, lost that a few hours ago)?

Quentin Campbell

cog.rusty’s picture

I guess you created the subdomain using your cpanel.

Usually when you create a "dev" subdomain to be accessed as "dev.example.com", your cpanel creates a corresponding subdirectory which is named just "dev", that is, "public_html/dev"

So (usually) you delete that "dev" subdirectory and replace it with a symlink named just "dev", because this is where your subdomain goes. Give it a try.

symlink(".", "dev");

Max_Headroom’s picture

I had a subdomain created with Cpanel, but I removed it again with Cpanel (not by deleting the the subdirectory). Maybe that's where the spanner hit the fan.
I did as you said, and I am now the happy owner of 2 Drupal sites with a third in the works. :-D

Thanks Saint Rusty ;-)

Quentin Campbell

russgri’s picture

Since you are on a shared server, your php may be run as cgi ... phpsuexec sp?
If so you will need to use 755 or it will return an error.

Check out by running phpinfo.php.

hliverance’s picture

Rusty, I read with interest your very meticulous dialog about multisite setup for Drupal. Fantastic dialog, and very helpful! Your patience is astounding. So are you a saint?

I have a question. I'm working on a christian teaching website, I have a test server sitting in my office with two domain names pointing to my IP address. It seems I need something that you referred to as a "domain pointer" to point each one to its respective directory so I can get Drupal to implement the symlink method for managing multiple sites. What do I have to do to set this up? Is this a function of the Apache WebServer? Thanks for your help.

cog.rusty’s picture

If you have full control of Apache, it should be only an Apache matter -- no symlinks required. In that case what you need to do is to set up Apache vhosts for the sites. Either in apache/conf/httpd.conf or in apache/conf/extra/httpd-vhosts.conf (depending on your Apache version) you can add a couple of vhosts with something like this:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName domain1.com
    ServerAlias www.domain1.com
    DocumentRoot "/blah/blah/drupal"
</VirtualHost>
<VirtualHost *:80>
    ServerName domain2.com
    ServerAlias www.domain2.com
    DocumentRoot "/blah/blah/drupal"
</VirtualHost>

Notice that the document root for both sites is already the same full path, Drupal's installation directory, so you don't need any symlinks -- just Apache.

Symlinks are only needed in some standard shared hosting setups where cpanel automatically puts the sites on different directories, in which case you need to bring them together.

hliverance’s picture

Symlinks are working now. But, since I do have full control of this server, I will try the Apache Virtual Host method. Thanks so much for your help!

skhatri’s picture

possible to share 1 multi site drupal? i guess symlinks won't work across accounts as 1 account won't have perms to the other. other methods? this capability would be enormously beneficial, as you can imagine.

Shahnawaz Khatri, owner
Internet Marketing 4 Real Estate
www.internetmarketing4realestate.com

lgwapnitsky’s picture

How would I go about creating the symlink without shell access or something like cPanel? I only have FTP access and would like to implement this.

Thanks,
Larry

cog.rusty’s picture

See above http://drupal.org/node/107347#comment-187038
You need only FTP.

The details may vary slightly, depending on where you have your Drupal directory and to which directories your other domains/subdomains point.

For example if Drupal is on your web document root and you have subdomains which point to subdirectories, then it would be like this http://drupal.org/node/107347#comment-200167

yngens’s picture

subscribe

c0mputerking’s picture

Hello i have installed drupal 5 and the multisite module however i cannot get the multisite module to work correctly. I sort of have it working but not really it seems to create the all the sites in the same place ie example.com takes me to a main site where i can access all the other sites created by the multisite module. Therefore i have tried to create the multisites manually using this how to for dummies.

I use webmin to generate new websites and have full control over my server. Webmin is setup to create
A user named example and a group also named example with shell access and a home directory of /home/example
A dns entry or A record for the new site that points to example.com
A apache vhost for the new site example.com that points apache to /home/example/public_html/drupal looks like this


ServerName example.com
ServerAlias www.example.com
DocumentRoot /usr/home/example/public_html/drupal
ErrorLog /usr/home/example/logs/error_log
CustomLog /usr/home/example/logs/access_log combined
ScriptAlias /cgi-bin/ /usr/home/example/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5

Options Indexes IncludesNOEXEC FollowSymLinks
allow from all


allow from all

A mysql user and database both named example
After alot of time and effort i made all of this work

Now for the drupal stuff, how do i make drupal multisite work correctly either manually or with the module??
manually I have tried creating the directory /usr/local/www/drupal5/sites/example. I then copied the settings.php file from the sites/default directory to the sites/example directory.

I made the following changes to the settings.php file to match up with the new drupal site i am trying to create

$db_url = 'mysql://example:examplepassword@localhost/example';
$db_prefix = 'drupal_';

Then I sym linked it to /home/example/public_html/drupal using this command
ln -s /usr/local/www/drupal5/sites/example/ /usr/home/example/public_html/drupal
Apache just serves a directory listing page with settings.php not a durpal site.

I would prefer to have the entire multisite except for the core files contained in the users home directory but do not really care and can use sym links pointers whatever i just want multisites to work.

PLEASE HELP I AM GOING MAD

Here is the code that mutlisite module suggested i add to my settings.php and below is the setting the recommend for apache.

#----CODE BEGIN-----
$requri = explode('/', request_uri());
if (sizeof($requri) >1 && $requri[1]=='site' && $requri[2] != '') {
$my_site_base = $requri[2];
# #this will be the database shared between the main site and the shared sites
# have changed this confused
$db_url = 'mysql://example:examplepassword@localhost/example';
#
$db_prefix = $my_site_base."_";
$base_url = "http://example.com/site/$my_site_base"; // NO trailing slash!
# }
# ----CODE END-------

I am confused as to what is going on here the shared database? I would like to have drupal create its entries in the users database and not share or do need to share some stuff but not all??

Also my site base?? where does this come from and will it substitute example.com somehow?

base url again what is going on here looks good but something is wrong


AliasMatch ^/site/\w+/(.*) /usr/local/www/drupal5/us$1
DocumentRoot /usr/local/www/drupal5/

# WARNING:CLEAN URLS demand a much more complicated setup with a bunch of rewrite rules.
# See the Appendix in this file for details

cog.rusty’s picture

I am only talking about a manually created multisite (no multisite module).

I have tried creating the directory /usr/local/www/drupal5/sites/example.

The name of the directory for any site should be a full site URL, such as:
/usr/local/www/drupal5/sites/example.com
/usr/local/www/drupal5/sites/www.example.com
/usr/local/www/drupal5/sites/example.com.subdirectory
/usr/local/www/drupal5/sites/subdomain.example.com

Then I sym linked it to /home/example/public_html/drupal using this command
ln -s /usr/local/www/drupal5/sites/example/ /usr/home/example/public_html/drupal
Apache just serves a directory listing page with settings.php not a durpal site.

What is "/usr/local/www/drupal5" and what is "/usr/home/example/public_html/drupal"? Is Drupal installed in a completely different place and you want to redirect to that? If so, make sure that "/usr/local/www/drupal5" is web accessible.

If you are trying to redirecto to Drupal's sites/example (or sites/example.com) directory, this is wrong. The /sites subdirectories are only intended for internal use by Drupal. In a Drupal multisite, the requests for all the sites go to Drupal's installation directory, and Drupal's index.php is run, it compares the request with the names of the /sites subdirectories and serves the appropriate site.

If what you want to do is have the vhost lead to "/usr/home/example/public_html/drupal" which is a symlink, and you have Drupal currently installed in "/usr/local/www/drupal5", then you would use:

ln -s /usr/local/www/drupal5 /usr/home/example/public_html/drupal

Also, it is safest not to set a $base_url in any of the settings.php files if there is no special reason. Sometimes adding a "www" where it is not needed can cause problems with login, or an old setting may be forgotten there after a domain change. Without a $base_url Drupal can adjust for these cases automatically.

Seneschall’s picture

Referring to

Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file ("database.sql").

I searched the initial zip file for the mysql file, but i'm either blind due to a 4 day migraine, or it's not there (drupal 5.2). Is it just as possible to export an initial sql installation via phpmyadmin, then edit it in notepad & import that to the new database?

If not... where is the sql file?

cog.rusty’s picture

That was written for Drupal 4.7.

In Drupal 5
- there is no "database.sql" file and the installer itself does the "editing" for table name prefixes (if any).
- you don't import the initial tables yourself
- and you don't put the $db_url yourself in your settings.php (or else the installation will fail).

Just skip steps 3 and 6 of that section, and at the end point your browser to that site's URL.

Seneschall’s picture

Got the symlinks down (I think). www.symlinked.com is going to www.drupalinstall.com. But it's not creating a multisite. It's only a forward.

I have /sites/symlinked.com
/sites/symlinked.com/themes
/sites/symlinked.com/settings.php

I tried using the default settings.php copied onto symlinked.com's folder. That only brought me to my main page, and when i change something on symlinked.com, it changes drupalinstall.com also.

So I changed the settings.php to look for a separate database. Now the page is blank and it's not asking for an install or anything. Did I miss a step somewhere?

I made the symlink forward directly to drupalinstall.com, not drupalinstall.com/sites/symlinked.com. This is right, from what I read... right?

cog.rusty’s picture

If symlinked.com brings you to Drupal at all, then it points to the right place and your symlink is right.

The question now is why Drupal cannot tell them apart.
- Do you have any custom apache rewrite in your .htaccess which changes the URL to the first one?
- What are your sites directory names? Are they

sites/drupalinstall.com
$base_url = 'http://www.drupalinstall.com'; // or commented out with a #
$db_url = '***first database settings***'

sites/symlinked.com
$base_url = 'http://www.symlinked.com'; //force that, just in case
$db_url = '***fresh, as uploaded***';

Is the new directory readable by apache? (755)
Is the fresh settings.php file readable and writable by apache? (666)

Seneschall’s picture

Drupal is installed at the main level. i.e. www.drupalinstall.com and not in any folders inside.

where the symlink should be reading the info is www.drupalinstall.com/sites/symlinked.com but instead it goes to the toplevel.

The .htaccess is the one that came with the drupal 5.2 download.

Everything is chmodded correctly.

No changes are to be made in the settings.php part for drupal 5.2? Or do the above changes have to be made if I want a separate database and/or drupal_ indicator on the DB?

cog.rusty’s picture

All domain names must lead to Drupal's single installation directory, using symlinks or any other method. Drupal's installation directory is probably public_html or something like that. It is a disk directory, not a domain. All domains must lead to that directory.

This is necessary for Drupal's index.php to run. Without going there, no domain can launch Drupal.

Then Drupal's index.php checks the requested URL and compares it with the names of those subdirectories you created.
- If it finds a match, it uses its settings and brings up the corresponding site.
- If it doesn't find a match, it uses the settings found in sites/default.

So, the /sites/symlinked.com directory is Drupal's internal business. Drupal knows where to find it, no symlink is needed for that.

If the request URL for any domain reaches Drupal's index.php unchanged, then the procedure should work. I can't think of anything else.

Seneschall’s picture

I'm wondering if it's something in my control panel then. I use HSphere as my control panel. Quite nice, similar to CPanel from what I hear.

So NOTHING gets changed on settings.php with Drupal 5.2 then?

Seneschall’s picture

Here's something... when I point the symlinked.com/settings.php site to a db that doesn't exist, it'll tell me this. However, when I point it to an empty db that DOES exist, that's when it goes blank. Does this help any?

Seneschall’s picture

That was very odd. By mistyping the info onto the settings.php sheet, I got to the correct page to allow the installation. I now have my multisite!

Cheers, cog.rusty for all your help!

Seneschall’s picture

Also... the step by step guide doesn't exist anymore. Anyone know of a different one? I'd be happy to add it to my own site if I can get all this working.

Cheers!

cog.rusty’s picture

There is a bunch of pages here. Not all apply to Drupal 5.

Multi-site installation and set-up
http://drupal.org/node/43816

danielslwu’s picture

can someone please help with my query here?
http://drupal.org/node/186276

i'm using drupal 5.2

esadot’s picture

I followed above instructions and was able to configure multi site, though needed to change the symbolic link command a bit to be run from the root directory: "ln -s . drupal-installation-directory/. sub-domain". Thanks.

So I've three sites, domain, and two sub-domain, all are working sharing single code base. On issue remain though, I can't run cronjob for my sub-domains. Cronjob only runs for the main domain.
Executing "php -q /home/username/domain/cron.php", runs domain's cronjob.
Executing "php -q /home/username/sub-domain/cron.php", actually also runs the domain's cronjob, and not the sub-domain's cronjob.

Directory structure:
sites/all/modules
sites/all/themes
sites/default/settings.php - where $db_url and $base_url pointing to the domain.
sites/sub-domain-1/settings.php - where $db_url and $base_url pointing to sub-domain-1.
sites/sub-domain-2/settings.php - where $db_url and $base_url pointing to sub-domain-2.

Appreciate an advice here.

Thanks in advance,

cog.rusty’s picture

Notice what it says near the end of this page:

http://drupal.org/cron

Cron is supposed to run for each domain separately, using an URL and not a file path. This is done using a browser such as wget or lynx or curl, not php.

A cron job is supposed to update one site's database. Perhaps it so happens that running cron.php as a file does update the default site's database, but this is undocumented, hence accidental.

esadot’s picture

Stupid me, apparently this should be the line in the crontab: 10 * * * * /usr/bin/wget -O - -q http://sub-domain/cron.php

sonicthoughts’s picture

Am i the only one with a problem? Spent 3 hours with cron!

HiFiGuy36’s picture

This one ended my hours of wrestling with cron as well.
I had it working for my first site, but not subsequent sites. I assumed that since cron.php was in my html root, that the one crontab would work for all.

darumaki’s picture

Drupal multi-site is amazing, can't believe how easy it was, tried it out on localhost,

I have a question about cpanel and doing this on live server, what if you already have domains setup pointing to different locations (non-drupal sites)
now that i have my local drupal ready to go I'll be uploading to server and switching all sites to drupal

with a drupal multi-site setup we would have to redo the paths and direct those domains to the drupal root, can this be done in cpanel ? Does Cpanel allow you to point a domain to an existing domain
I don't see any options to change or is this a parked domain function

I would hate to have to delete all add on domains and re-add them

Any recommendations ?

Imago’s picture

Just leave the old sites as they are, with the same virtual hosts in httpd.conf

What you have to do is to

1. create the new site under /sites/ as explained,

2. move all the content of the old site DB to a new DB, created by cPanel in the Drupal site and using one and the same user as the rest of your sites in the chain.

3. delete the old site's username dir in the home/ of your server, and

4. Create a symlink from the installation root of your basic Drupal to the /home/username of the old site

You have to create also a common DB for the shared user-related tables, but you can surely use the default DB.

Imago’s picture

This works better for new sites. Delete the addon subdirectory in the Drupal root and create symlink to it.

vacilando’s picture

One for St Cog Rusty...

I am ashamed to say I have spent days trying to solve this, without success:

I am on CentOS 5, Apache 2, in full control of the server. Domains set up using Plesk 8.

I have set up many, many multisite systems on a different Linux system and under different control panel. But here I am really lost!

Concretely: basically I have the core Drupal install running fine in /var/www/vhosts/sitename.tld/httpdocs/

Then there is another website running in /var/www/vhosts/sitename2.tld/httpdocs/ -- this is not a Drupal site, but I am porting it to Drupal. For that purpose, I have, using Plesk, created a subdomain called lab.sitename2.tld which Plesk physically created as /var/www/vhosts/sitename2.tld/subdomains/lab/
The default index page in there displayed at lab.sitename2.tld, so I knew the subdomain was set up properly.
So I went to /var/www/vhosts/sitename2.tld/subdomains/, renamed 'lab' to something else and went ahead with this symlink: ln -sv /var/www/vhosts/sitename.tld/httpdocs/ lab

Then I went to the browser and tried lab.sitename2.tld ... but I always keep getting "403 Forbidden You do not have permission to access this document." I looked at error_log for sitename2.tld and that says: "Symbolic link not allowed or link target not accessible: /var/www/vhosts/sitename2.tld/subdomains/lab"

Somebody told me to make sure that /var/www/vhosts/sitename2.tld/conf/httpd.include contained
Options FollowSymlinks
inside
<Directory /var/www/vhosts/sitename2.tld/httpdocs>
and
<Directory /var/www/vhosts/lab.sitename2.tld/httpdocs>
so I've added that between these directory tags for both :80 and :443 ... no change, again the same error message!

I also made sure that settings.php in /var/www/vhosts/sitename.tld/httpdocs/sites/lab.sitename2.tld/ is chmod-ed to 755 (though I do not think Apache is getting that far as yet, really).

I also tried to keep the real /var/www/vhosts/sitename2.tld/subdomains/lab/ and symlink just ln -sv /var/www/vhosts/sitename.tld/httpdocs/ httpdocs within it... with same results.

What I am confused about is that sitename.tld and sitename2.tld are "owned" (on Linux filesystem level) by two different users, but in the same group. I keep saying to myself this should not be an issue because Apache has access to both, yet I mention it here for completeness.

I really hope this strikes a familiar note in Cog or other multisite-experts in here, because I am totally out of ideas and energy right now!

Cheers,

Tomáš / Vacilando

darumaki’s picture

Is it possible to setup the multi-site files first but instead of editing the settings file, leave it new and install a fresh drupal for that domain ? I tried it but doesn't appear to work, for multi-sites does the drupal database have to be created first ? It would be nice if we could install separate for each domain that way it doesn't cary over content from another domain.

vm’s picture

content shouldn't be carried over if you are using a fresh (from a new download) settings.php

using a fresh settings.php will force installation of the next site in a multisite where you will go through the process of installing just like you did for the first install.

the DB should be created first. Drupal doesn't create a DB for you.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

darumaki’s picture

right, I got it to work, guess the folder in sites has to be named same as the domain in order for it work

vm’s picture

guess the folder in sites has to be named same as the domain in order for it work

That is correct and is so stated in the Original Post.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

leenark’s picture

I was going through this thread. and looks like there are people like cog Rusty having tremendous patience.
Like others I am lost in this Drpal: multisite one codebase, symlinks and where to put subdomains etc.
I will go straight to my Q's.

My drupal server settings:

My drupal baseURL is http://www.is-watch.net/ which points to home/username/public_html/index.php in the filesystem.
I am trying to have new site from same drupal codebase, with diff database for the site
I have created a subdomain called http://india.is-watch.net/
and it points to directory called as: “iswindia” which is outside public_html.

My questions are:
1. should subfolder name for my subdomain reflect it exactly as in subdomain? As in my case if it is, http://india.is-watch.net/ then subfolder should be “india”? Or that doesnot matter I have diff name as “iswindia”.
2. In order to run new site, do I copy settings.php file under “iswindia” (which is outside public_html) or should this directory be inside public_html?and I copy settings file under "site' folder. Then I make settings.php writable (666).
3. Now can I copy database for main site and have it under new name for new site? As I will be sharing data from there. I will setup username and passwd with all priveledges for this database, and need to reflect these changes in settings.php?
4. If I want different look and feel to new site, where do I need to make changes, the template?do I need to copy all modules, templates under sites/newfolder?
5. Now where do I put symlinks?
Is this how I make makemysymlinks.php and where does this go?
symlink(".", "subdomain"); ?

symlink("home/username/public_html/ ", "home/username/iswindia"); ?

I appreciate all your help in this matter.

vm’s picture

1. should subfolder name for my subdomain reflect it exactly as in subdomain? As in my case if it is, http://india.is-watch.net/ then subfolder should be “india”? Or that doesnot matter I have diff name as “iswindia”.

If your site is .. is-watch.net, and you have a subdomain called india.is-watch.net , your directory in sites, should be india.is-watch.net

/public_root/ <- your drupal install
/public_root/sites/india.is-watch.net <- your subdomain

2. In order to run new site, do I copy settings.php file under “iswindia” (which is outside public_html) or should this directory be inside public_html?and I copy settings file under "site' folder. Then I make settings.php writable (666).

A best practice would be to download a fresh copy of drupal and use a fresh settinsg.php file

3. Now can I copy database for main site and have it under new name for new site? As I will be sharing data from there. I will setup username and passwd with all priveledges for this database, and need to reflect these changes in settings.php?

If you are sharing content , you don't want seperate DB's, you want to install your multisites in the same DB, using a DB prefix
you then open settings.php and find the array that allows you to share tables and adjust as needed.

4. If I want different look and feel to new site, where do I need to make changes, the template?do I need to copy all modules, templates under sites/newfolder?

after your install your first multisite, you create a sites/yoursubdomain.com/themes folder & sites/yoursubdomain/modules folder
themes and modules you only want to run on this multisite install should be uploaded to these folders.

if you have a module or a theme you want available for use on ALL installs, you create a sites/all/modules & sites/all/themes folder and upload to these locations.

5. Now where do I put symlinks?
Is this how I make makemysymlinks.php and where does this go?

investigate your hosts KB, you may not have to use a symlink, if your host allows you to choose your document root after/during creation of your subdomain.

example: after I create a subdomain, I have an area in my host panel where I can tell that subdomain to use my main installs document root.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

leenark’s picture

Although all my question have been answered, after reading through I am more confused …Pl. I need some more help…
Following is my situation:
I have one site running in Drupal 4.7 (www.is-watch.net)
I want another site on same platform with its own DB (this site will have different content)

Following are the steps I need to follow to achieve this:
1. I need to set up subdirectory by subdomain name in “sites” folder and copy settings.php there: sites/India.is-watch.net/settings.php
2. Configure settings.php for new DB
$db_url = "mysql://username:password@localhost/databasename";
- "username" - the username for connecting to the new database
- "password" - the password for that username
- "databasename" - the name of the new database

ok. so far so good, When do I populate this DB? Can I point site to empty DB?currently it is empty no tables yet.

3.After this copy all the Modules (specific to new site)under sites/India.is-watch.net/modules
and new site specific templates under sites/India.is-watch.net/templates

3. Then I need to point browser to http://india.is-watch.net
It will ask me to, Create an account and login.
The first account will automatically become the main administrator account with total control.

Is this all I need to do in order to have new site running(using multisite setup)?

“investigate your hosts KB, you may not have to use a symlink, if your host allows you to choose your document root after/during creation of your subdomain.”
No I do not have access to create subdomain using Cpanel. Everytime I need to make request to host if I need one. Can you pl. explain it further “investigate your hosts KB”?

thanks

vm’s picture

1) yes
2) you populate the DB after you have everything in place, just as you did when you set up your first installation.
3) yes that is all you need to do provided you have followed all directions.

No I do not have access to create subdomain using Cpanel. Everytime I need to make request to host if I need one. Can you pl. explain it further “investigate your hosts KB”?

Not sure what you want me to explain further here. If your host doesn't allow you to set up subdomains then there is nothing left to explain. If your host is setting up the subdomain for you, have them makre sure the doc root of the subdomain is the domain of your 1st installation.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

Sree’s picture

subscribing!

-- Sree --
IRC Nick: sreeveturi

leenark’s picture

Thanks, I got most of my doubts clear. thanks for answering all my (somewhat) dumb q's.

One last Q:Regarding "doc root of the subdomain is the domain of your 1st installation."

So since I got subdomain created already it is currently pointing to some directory outside "public_html"
now all I need to ask for is have this subdomain point to main root folder? i.e. "public_html"? not sure if I got it right here.

Thanks

vm’s picture

the subdomain doc root must point to the drupal installation, if you have drupal installed in public_html then that is where you want the doc root for the subdomain to point.

Admittedly, I do things a bit different when I am using subdomains and multisites.

My main install is also in a subdomain:

example:

public_root/main <- main installation of drupal
public_root/dev <- dev multisite

I then redirect traffic to the subdomain named "main" I do this to avoid excess directories in in the drupal install root.

Whether you do this or not is up to you, I've found it easier, cleaner and to be less of a headache in the long run.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

leenark’s picture

Thanks, It was very clear. I will now go ahead and try to setup multi site env.
Hopefully it will all go smooth.

leenark’s picture

AS per suggestion on forum I have done following but still unable to get it to work:
Main site is at www.is-watch.net, inorder to create india.is-watch.net

* i have subdomain (india-is-watch.net) I have new database created and user with full privileges
I do not have option to create subdomain thr' Cpanel, web host created it for me
* Using ftp, created a sub-directory in the "/sites" directory called "india.is-watch.net"
* Copied the /sites/default/settings.php to the new directory /sites/india.is-watch.net/settings.php
* Made changes to the following line in the new settings.php file
$db_url = 'mysql://db-username:db-password@localhost/new-db-name';
* Created a symlink from the new location to the main site, using PHP script
(I assume subdomain should be pointing to public_html/sites/india.is-watch.net directory)

symlink('/home/user/public_html', '/home/user/public_html/india.is-watch.net');
print "Done";

named it as "makemysymlink.php" and transfered it to where Drupal installation is (public_html)
then tried to run it by pointing browser to : http://www.is-watch.net/makemysymlink.php
After this point I am getting error
"Warning: symlink(): Permission denied in /home/iswatch/public_html/makemysymlink.php on line 2
Done"

Don't know where is it gong wrong.

vm’s picture

The subdomain needs to point too the folder that has drupals index.php in it. Which allows it to use your main drupal installation as its code base.

when your host creates the subdomain for you, just inform them to make the subdomains docroot your main drupal install directory.

Doing so avoids having to use a script to create a symlink.

_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

leenark’s picture

Ok, after following your last hint...I asked my host to point subdomain to public_html directory where my main drupal installation is, it is working.
india.is-watch.net

I created new account...don't think it has got full privileges..as everytime I submit some info it keeps going back to main site
www.is-watch.net

am i missing something here?
Do I need to change $base_url property in settings.php file for new site (public_html/sites/india.is-watch..net)
as with new site name.

* The URL of your website's main page. It is not allowed to have
* a trailing slash; Drupal will add it for you.
*/
$base_url = 'http://www.is-watch.net';

please advice.

vm’s picture

you certainly can't use the main site base url in the subdomain.
If you had used a "new" settings.php that base url wouldn't be there.

remove the base url and test. most times you won't need a base url with any site.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

MatthijsG’s picture

I skipped step 3 - 6 and also 1 and 2 :-)

I just made in sites/ a new dir called domain2.tld and copy&paste the settings.php (line 93~ 113). After that, i ran domain2.tld/install.php and just followed the steps.

Maybe i'm missing something, but i didn't have to do anything with symlinks (however, i had the .htaccess already modified : pointing to /public_html/site where domain1 is)

======
There are 10 people who can count binary
They who can and they who don't

walterbyrd’s picture

I am using lighttpd, which - I think - does not use .htaccess.

leenark’s picture

Yes, after i changed base url attribute in settings.php for new site it worked.

Swift Arrow’s picture

Hi I hope someone knowledgable is going to read this soon...

from my reading this whole thread ("whew!"), I can understand the following:

1) domainname.tld (or subdomain.domainname.tld) must point to the drupal codebase folder.
2) If it doesnt point there, it should point to a symlink which points to the drupal codebase folder
3) Drupal needs a folder called "domainname.tld" (or subdomain.domainname.tld) in /sites/ so that it knows where to pull domainname.tld from
4) When setting it up, settings.php in /sites/domainname.tld/ (or /sites/subdomain.domainname.tld) should be fresh out of the box

Those four steps are easy enough (am I right regarding the subdomains?)

Here's my situation:

I'm running drupal off of my memory stick on Webserver On Stick (apache/php/mysql) in WinXP. I dont want to edit any files on the pc.

In the address bar we have: http://localhost/drupal/ as the code base, which works fine. Now I want to multisite so that I can experiment properly, with less risk of breaking my install, and the ability to compare results, etc.

My Ultimate Aim is to get it all up and running properly, and mirror it all up to my webserver (and migrate the databases) without having to go through the pain of enabling the modules, changing the configuration settings, and re-theming. If those four steps above are ok, I should have no problem whatsoever.

Here's my Problem:

I just want to know how I would access the different sites using localhost/drupal/something or other. Would that be possible?

Thanks...
BTW, I think that a permalink should go to this thread - it is the ultimate source on multisiting...

lappies’s picture

swiftarrow, Here is your answer discussed in detail
http://drupal.org/node/32715

Hope this helps.
I followed it and BINGO!

Swift Arrow’s picture

Thanks, I will try it.

I tried what I have written above, and it seems that it is not quite enough... So I will try that solution.

walterbyrd’s picture

I have VPS hosting. I have drupal 5.5 installed, and working, in /var/www/.

I have a second domain in /var/www/d2.com/. I can access this domain with the URL d2.com.

I have tried this:

ln -s /var/www/ /var/www/d2.com

but that only creates a directory called www within the /var/www/d2.com/ directory, which points to /var/www/. i.e.:

server:/var/www/d2.com# ls -l
total 0
lrwxrwxrwx 1 root root 9 Jan 4 08:12 www -> /var/www/

Imago’s picture

You have first to create the new domain, then delete its direcory in /var/www/. Or create an addon domain and delete its dir in /var/www/d2.com/ If the latter, create symlink

ln -s /full_path_to_html_dir/ /full_path_to_html_dir/foo

doudou’s picture

Thanks for your post, it was very helpful, I got my subdomain up and running in no time. But when I created the first superuser, I was unable to login back in once I logged out. I treid creating another account, same problem. The only way I could login in is by reseting my password and drupal emailing me a link. In the end I had to close browser and clean out all temp files before I can login. Maybe it has something todo with cookie session. Has anyone else had this problem? How did you solved? I still use drupal 5.1

geoline’s picture

Hi folks,

thanks for the grat tips. Based on your posts I now host more than 20 domains with one drupal installation and its working fine.

Greetings
geoline

webjourneyman’s picture

> Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file >("database.sql").

What is suitable modificaton of database.sql?

>Create a symlink from the new location to the main site, using the command (for example):
>ln -s /home/username/public_html/
>/home/username/public_html/domainname2

How do I create a symlink?

In my cpanel > domains I can select between addon subdomain and parked, which one should I use?

MatthijsG’s picture

I registered a new URL, but i can't get the URL working :-(

Like my other domains, i forwarded domain3.tld to the drupal directory. Exactly the same code in the htaccess, except for the name.

I created a subfolder in /sites, /sites/domain3.tld and copy&pasted the settings.php. I altered some info (prefix) in settings php. So far, so good.

Then i would like to run domain3.tld/install.php to create the right tables. But this doesn't work :-( Drupal thinks i upgrade my main site. When i skip this step, and go to domain3.tld I get table-missing errors. I should install some tables in mysql. But what is the right way to do it? And why can't i do it with install.php anymore?

* edit: somehow (badly i don't know exactly how :-( ) i got the install.php with a lot of errors running. After that, i could log in with my main-site password. Grrmbblll i just want to know what i did ...

======
There are 10 people who can count binary
They who can and they who don't

webjourneyman’s picture

I'm using drupal 5.7 (just noticed this is for 4.7) and cpanel and only got multisites working yesterday, what was tripping me up was that the process had become a lot simpler than I expected, there was no need to change settings.php, htaccess or the db settings by hand, the drupal installer took care of it all, it boiled down to 9 steps, see my comment: http://drupal.org/node/156720#comment-727700 .

darumaki’s picture

Does anyone know if multi-site will be available in Drupal 6 ? I tried it and it appears to not work or maybe it works a different way ?

MatthijsG’s picture

I installed Dr6 for 2 domains to test Dr6.

- First, installed drupal the normal way.
- Then, made a subdir in /sites/domain1. Modded the settings.php (i think, this is the place where the most errors come from).
- made /sites/domain2 and modded settings.php
- and both domains are working now. First there was a problem that only errors where shown (couldn't find table etc). This was pointing me in the direction that the config of the settings/php wasn't good.

Maybe i did something else, but this 'simple' way works for me.

======
There are 10 people who can count binary
They who can and they who don't

darumaki’s picture

with Drupal 5 you just point to browser domain url and the install took care of the rest, no need to edit the settings.php seems with Drupal 6 this is no longer the case

ronklaren’s picture

Creating multisites with drupal was easy enough, but now I have a problem creating emailaddresses.

My host provides Direct Admin for setting up domains etc., and making a drupal multisite is as easy as creating the main domain and creating domainpointers for the client domains.

So I now have:

www.mymaindomain.nl
P: client1domain.nl
P: client2domain.nl
P: client3domain.nl
etc.

Problem is, that when I want to create emailacounts, it only lets me create acounts for www.mymaindomain.nl and not for the clientdomains. Does anyone have experience with Drupal/Multisites/Direct Admin?

Ron

the fatman’s picture

Don't know about DirectAdmin but cPanel gives a dropdown menu with the url's in it when you're adding an email account and the parked domain shows up there so it must be possible. Do you have shell access?

I got multisites up with 5.7 by the way, thanks heaps.

lubos-1’s picture

Hi all,
as I can see there are people over there who want to use multisite installation of Drupal.
I needed the same as I host a number of websites. My situation is a bit different than that of you who use hosting companies. I run my own home server on Debian Etch with ISPconfig (free hosting software). When i looked for multisite installation instructions I found an tutorial for installation of Drupal 4.7 on Debian with ISPconfig at http://www.howtoforge.com/drupal_ispconfig. Another tutorial I found is for multisite installation of Drupal on Ubuntu (no ISPconfig) and it is located at http://www.howtoforge.com/multisite_drupal_installation_ubuntu. As my server is Debian with ISPconfig and I wanted to install Drupal 5.6 at this time, I wrote my own easy-to-follow copy-paste tutorial. It is located at http://www.howtoforge.com/drupal-5.6-with-ispconfig-on-debian-etch.
Right now I am working on tutorial for multisite installation of Drupal 6.1 on Debian Etch with ISPconfig. Since I have bit a problem with default .htaccess file in Drupal 6.1 (the Apache server is configured different way for ISPconfig and I have to find what exactly is causing an internal error) that tutorial is not done yet. When it will be available I will surely post link to it here.
A bit of background - I installed and tested several different CMS before I finally stick with Drupal. I am still learning how to configure it and not all what I would like is running smoothly yet, however there is huge amount of documents and Forum seems to be live enough. Actually this is my first posting on drupal.org as all, what I needed before, was already answered in one place or another. The modules depository is impressing and themes are not behind. My conclusion? If you are not convinced yet about Drupal just give it a try and you will end your search for CMS here.
BTW I would like to express a big

thank you to all developers

And small add targeted onto all others: If you like Drupal why not become a Member of Drupal association for only €22 per year? See https://association.drupal.org/membership for details.
Happy Drupaling ;-)

aharon1’s picture

Hello everyone,

I'm really excited about working with Drupal. I can't find the answer to my question, maybe someone can help.

I have an installation on my server with subdomains that are working:

My server is www.mysite.com
my subdomain is customer1.mysite.com

My customer has his domain parked at www.customersite.com

My customer is using godaddy and so am I.

When I park the domain and set forwarding (301) to customer1.mysite.com , it works, but the links do not point to www.customersite.com, they point to customer1.mysite.com. I understand why its doing this, but what is the preferred method to having this work, a CName? I can't use symlinks because its not the same server.

Please help geniuses!!!

Thx.

mkahn’s picture

Wow - i made it through a lot of posts, talking about simlinks file systems and pointers (Oh my!)

My question is less technical, and more functional in nature. People here seem to be talking about 'multisites' but now really defining what you mean by that. If its simply having a subdomain with a folder, which is what it seems to be talking about, i dont get it what the big deal is. you have a drupal site, with apache (or the fs) configured to serve a different website to the subdomain.

I need a multisite which will serve a different subset of drupal content to a different subdomain. eg craigslist. sfbay.craigslist.org serves regional content, however the forum area still accesses a globalized database. I want to be able to publish content and specify if its for regional or global distribution. So I'd have www.mysite.com displaying global content exclusively, and regional.mysite.com displaying a mix of global and regional content, based on what content is available in the database that is categorized for that region.

Is this what everyone else on here is talking about? Is this possible natively, or using some cck type functionality, or am i way out on a limb here?

Thanks!

Mark Kahn,
Droople Apprentice

Imago’s picture

"If its simply having a subdomain with a folder, which is what it seems to be"

Hi, Mark!

It is quite the contrary - to have a separate site without a special folder for it. What is more - if you have such a folder, you have to delete it in order for multisites to work properly. It's more of a kind of virtualization technique. You create virtual folders (symlinks) in place of the actual folders.

You may want to look also at this project

http://drupal.org/project/virtual_site

mkahn’s picture

Thanks for your reply, Imago!

I checked out the link to the project you mentioned, and i'd like to be clear. It talked about differentiation on subdomained multisites, but I'll still be able to serve information to global as well as regional databases, correct?

the subdomain gets transformed into an argument passed with the url to theme, and custom populate the sub-site with a mixture of global and regionalized content, through a config file mapped to that argument.

Maybe thats the phrase I've been looking for.. Is that accurate?

Mark Kahn,
Droople Apprentice

georgelai’s picture

I have a similar need to what Mark was discussing. I would like to have the user select which region he would be interested in seeing, and based on his selection, he would be taken to a subdomain, with content specific to that region.

Furthermore, any new content he creates at that subdomain will save into the sql database for that region.

And if he logs off and then logs back in and selects a different region/subdomain, then the appropriate database is retrieved showing that region's content.

Is that possible with virtual site?

I have set up a drupal site with 1 subdomain, which maps to a different database. However, the user has to log into the two domains separately. I would like to have one login for all sites.

- George

cog.rusty’s picture

Read http://drupal.org/node/147828

Modules which you can try are:

http://drupal.org/project/singlesignon
http://drupal.org/project/fierce_sso
http://drupal.org/project/multisite_login

Or, you could try a manual solution, sharing the users, sequences, sessions and authmap tables for all subdomain and editing all the settings.php files to use $cookie_domain=.example.com (without specifying a subdomain).

willgetitfixed’s picture

A bit lost would describe where I am currently.

the post "Multisites with a subdomain" suggests that I
# Using PHP MySQL or any other database application, create a database by the name "domain2"
# Grant full privileges to the database to the default user
# Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file ("database.sql").

I created the database, but I am not SURE how to grant all privs to the "default" user or how to use phpMyAdmin to modify the database or database.sql.

Also where (since I have already been working on my site) can I acquire a "fresh copy" of settings.php?

I am really new to Drupal and have limited knowledge of php and MySQL ... always more than willing to learn but you have to start somewhere.

I would like to create multiple subdomains ...
mydomain.com
site1.mydomain.com
site2.mydomain.com
site3.mydomain.com
site4.mydomain.com
site5.mydomain.com
.... I presume this possible from a single external IP with dunamic DNS?

Also, is it possible to take the content that has been created thus far and move it to a subdomain?

vm’s picture

you can handle subdomains using your host panel on the server itself. if you have to do it manually because you own your own server and are that severs sysadmin then you have to use http.conf (I believe)

if on a shared server, your host panel should allow you to set up subdmains and databases.

when you refer to "default user" what exactly do you mean ?

DB 1 uses its user and password
DB 2 uses its user and password

you don't haev to alter any file to create a second DB or tables you simply walk through another installation of Drupal as you did the first time when you get the "fresh" settings.php file

to obtain a fresh settings.php file download the drupal package from drupal.org and locate the settings.php file in sites/default
upload that settings php file to sites/yoursubdomain.domain.com folder
and point your browser to the subdomain
install.php will detect that it needs to run again and will do so.

I'd also highly suggest starting a new thread, This one is a bit convaluted at this point and it awfully long. It's also sitting in a deprecated forum.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

johnhorning’s picture

Under Multisites with a subdomain in the original post, I see this:

* Using cPanel or ftp, create a sub-directory in the "/sites" directory called "subdomain.domainname.tld"
* Copy the /sites/default/settings.php to the new directory /sites/domain2.com/settings.php

These 2 items mention 2 different new directories (subdomain.domainname.tld and domain2.com). Aren't we supposed to be talking about the same directory here? And does this apply to version 5.7?

John

cog.rusty’s picture

Yes, it should be the same "sites/subdomain.domainname.tld" directory.

"domain2.com" was apparently a copy/paste error.

willgetitfixed’s picture

Sorry for the confusion but obviously I have missed something.
I did as instructed to the best of my knowledge.

"if you have to do it manually because you own your own server and are that severs sysadmin then you have to use http.conf (I believe)"

I looked at http.conf and forgive me but that makes little sense to me.
Not sure if this is the one but "/var/webconfig/htdocs/mysql/contrib/packaging/Fedora/phpMyAdmin-http.conf"
is the only one I can locate. and I don't understand what to do to make subdomains. Looking at phpMyAdmin doesn't bring into focus that makes me believe I am in the right place.

I did create the sub.domain.tld and attempted to access the page and the page will not load.

I am very new to all of this and I would really like to learn how it all plugs together.

Is there someone that would be willing to point me in the right direction so I can make this a learning experience for myself and my kids?

cog.rusty’s picture

You are probably looking for the Apache configuration file, httpd.conf, where you can set up <VirtualHost> sections which define which domain or subdomain goes to which file path.

If you set up your server so that the URL http://sub.domain.tld points to the directory where Drupal is installed, then Drupal will use the settings which you have put in the subdirectory sites/sub.domain.tld

If this does not answer your question, try to explain better what is your subdomain's URL, to which directory it points, and what error message you see when you go to that URL.

willgetitfixed’s picture

You are absolutely correct. After a little reading here http://httpd.apache.org/docs/2.0/vhosts/name-based.html and some alterations to my /etc/hosts I was able to access the drupal installation. Now it's a matter of figuring out write permissions ... AGAIN. I really should take better notes or regain some of my lost memory.

Thank you for your assistance.

luckysmack’s picture

I have 2 domains that are hosted on the same server (Dreamhost). Drupal 5 in installed into the site1 directory

mysite1.net (primary site)
mysite2.com (new site)

My primary site already has a running install of drupal 5.x . When setting up the new domain it was like this

root/myusername/mysite1.net
root/myusername/mysite2.com

I created the following:

mysite1.net/sites/mysite2.com
mysite1.net/sites/mysite2.com/themes
mysite1.net/sites/mysite2.com/modules
mysite1.net/sites/mysite2.com/settings.php (modded ot use a completley seperate mysql db)

First I tried pointing mysite2 directly to mysite1, no luck. It just brought up the site1. I tried setting up a symlink (using php, no shell access. waiting for it to refresh so i have access to it). I ended up with:

root/myusername/mysite1.net
root/myusername/mysite2.com ->. (pointing the the above directory) No luck

Currently my site2 is pointing to root/myusername/mysite2.com. I am unable to get this accomplished for some reason.
even though site1 is already built it is a fresh build and can start over if needed, but would rather avoid that. I have tried a few other things as well but i cant remember all of them. I downloaded the multisite mods but for some reason i cant upload stuff at the moment, not sure why. the ftp connection is just being stubborn. will try it later. Oh and for some reason a couple of symlinks i created earlier that I tried wont delete even though it shows me as the owner.

The other question I have is ive seen people using *.tld to signify addresses, is this juat a catch all term or a literal on, do I have to name the sites sub folders .tld (because I tried either way and no change)

Well any ides will be greatly appreciated

cog.rusty’s picture

I am not sure why your symlink does not work. It should. Make sure that you start installing the second site with a new clean settings.php file which doesn't already contain any database or base_url settings.

Symlinks created using a php script normally are owned by the web server ("apache" or "nobody"), so they can be deleted the same way, with a php script.

"tld" just means "top level domain" (com, net, org, a country etc). It is not literal.

luckysmack’s picture

Hea ok I've hearl that term top level domain befor,e. Didn't think of that.

Anyways yea. I will try putting a frees settings file.I had modified it for the new server. But would that give me the errors "no access privelages to view the page allso has a 404 error", or a "files in durectory" listing?

cog.rusty’s picture

If everything has been set up OK, the first time you visit the new subdomain:
- Drupal's index.php file will run
- it will look at the proper settings.php file (according to the URL requested by your browser)
- it won't find a valid database setting
- it will run install.php for the new site.

To avoid the messages you mentioned:
- An index.php or index.html file must exist in the target directory (Drupal has its index.php file)
- The server must be configured to automatically run that index file. (For this purpose Drupal's .htaccess file contains a DirectoryIndex index.php line.)

When either of the above is not true, and an index file either does not exist or does not run, then you get one of the two messages you mentioned, depending on the Options +Indexes or Options -Indexes line in your .htaccess file. (Drupal by default takes the second, more secure option, so that people can't list your files.)

willgetitfixed’s picture

OK maybe I am brain dead or something, but I am not using Cpanel or any other interface and I am using my own server which I have direct CLI and ssh access to. I just am not getting the whole symlink thing for seperate domains. My subdomains are working flawlessly (fingers crossed) but I also want to use a completely separate domain.

Here is what I have at this point in time:

If I go to my virtualdomain.tld (which contains a new untouched settings.php) I get a 404 error.
If I put an index.html in the virtualdomain.tld directory I see the page so I know it is accessing the directory.

Now my question is what exactly am I linking to what exactly.

I keep seeing "use this thing to create this, but remember that you must delete that and link this to over yonder"
My issue is I am not using "this" and I don't see an example of "that" that looks anything like what I have here ... SO if someone would be kind enough to kind of break it down a bit and be a little more elaborate on what "this" and "that" are I would be exponentially grateful, because I just want it to work and I *think* I am very close at this point, but something is missing from this recipe.

Please help.

cog.rusty’s picture

Now this may sound repetitive...

If I go to my virtualdomain.tld (which contains a new untouched settings.php) I get a 404 error.
If I put an index.html in the virtualdomain.tld directory I see the page so I know it is accessing the directory.

You mean the sites/virtualdomain.tld directory under Drupal, which contains the settings.php file?

You should never need to go there with a browser. This is an internal Drupal directory. Each and every domain or subdomain should lead to one and the same directory, Drupal's main directory.

You never need to access the sites/virtualdomain.tld directory with a browser. All your domains need to point to Drupal, and Drupal will check the request URL, compare it with its internal sites/virtualdomain.tld directories, and will figure out which site the visitor wants to access.

All the talk about cpanels and symlinks was about making the domain http://virtualdomain.tld point to Drupal's main directory. If you have full control of the server you can do this by editing Apache's httpd.conf file.

See: http://drupal.org/node/111238
Notice how the different ServerNames all use the same DocumentRoot directory where Drupal is installed.

willgetitfixed’s picture

Taking into consideration what you have said please look at these.

Keep in mind that the first one does not work and the next two do work.

-VirtualHost *:80>
ServerName domain2.tld
ServerAlias *.domain2.tld
DocumentRoot /var/www/virtual/domain2.tld
# DocumentRoot /var/www/html/sites/domain2.tld
ErrorLog /var/log/httpd/domain2.tld_error_log
CustomLog /var/log/httpd/domain2.tld_access_log combined
-/VirtualHost>

-VirtualHost *:80>
ServerName test.domain.tld
ServerAlias *.test.domain.tld
DocumentRoot /var/www/virtual/test.domain.tld
ErrorLog /var/log/httpd/test.domain.tld_error_log
CustomLog /var/log/httpd/test.domain.tld_access_log combined
-/VirtualHost>

-VirtualHost *:80>
ServerName test2.domain.tld
ServerAlias *.test2.domain.tld
DocumentRoot /var/www/virtual/test2.domain.tld
ErrorLog /var/log/httpd/test2.domain.tld_error_log
CustomLog /var/log/httpd/test2.domain.tld_access_log combined
-/VirtualHost>
.
.. but being a good student and following my mentor's instructions I did as you specified and changed it to read ..

-VirtualHost *:80>
ServerName domain2.tld
ServerAlias *.domain2.tld
# DocumentRoot /var/www/virtual/domain2.tld
DocumentRoot /var/www/html
ErrorLog /var/log/httpd/domain2.tld_error_log
CustomLog /var/log/httpd/domain2.tld_access_log combined
-/VirtualHost>

Now hopefully I will not fry something else. I am curious why the subdomains work, but the alternate domain MUST come from the higher level.

Thank you for the insight and patience.

Oh yeah ...
"You should never need to go there with a browser"
I only did this to make sure the dynamic DNS was working properly and it was.

Thanks

cog.rusty’s picture

Can you explain what's in the directories:


/var/www/virtual/domain2.tld
/var/www/virtual/test.domain.tld
/var/www/virtual/test2.domain.tld
/var/www/html

and in which directory is Drupal installed?

willgetitfixed’s picture

All /var/www/virtual/* are empty directories and obviously Drupal in installed in /var/www/html . I assume this because there are several .php files there that I did not put there myself. As I stated I am new to this whole Drupal, multisite, MySQL, webserver adventure. As for the "normal" content (index.html or whatever top level content) /var/www/html is where that would normally be on my feeble little server.

... Meanwhile back at the ranch ...

After further investigation I find that it does actually contain a few hidden files, user information and a file telling which site it corresponds to.

cog.rusty’s picture

To be sure which one Drupal's directory is, it should contain (among other things):

includes subdirectory
misc subdirectory
modules subdirectory
scripts subdirectory
sites subdirectory, containing a settings subdirectory for each site.
themes subdirectory
index.php file
install.php file
update.php file
xmlrpc.php file, and a few other files

So, you say that directory is /var/www/html. Then, for all Drupal sites, that should be their document root.

ServerName domain2.tld
DocumentRoot /var/www/html
....
ServerName test.domain.tld
DocumentRoot /var/www/html
....
ServerName test2.domain.tld
DocumentRoot /var/www/html

However, you say that:
- Your subdomain sites are working
- Their document root is set to /var/www/virtual/test.domain.tld and /var/www/virtual/test2.domain.tld, respectively
- The directories /var/www/virtual/test.domain.tld and /var/www/virtual/test2.domain.tld are empty directories.

This is puzzling. If a virtual server points to an empty directory, then that site just shouldn't work. Apparently I am misunderstanding something about those directories you have.

willgetitfixed’s picture

"This is puzzling. If a virtual server points to an empty directory, then that site just shouldn't work. Apparently I am misunderstanding something about those directories you have."

I am as well, but the sites are working none the less. As I said they do contain a hidden file that says nothing more than "Web Site - test2.domain.tld". Not sure how it fits into the grand scheme of things but there it is.

willgetitfixed’s picture

As far as I can tell I *think* the files and directories are related to FlexShares in some vague way, but I cannot find documentation to reinforce that statement. Nor am I sure how they were created. Sorry for th confusion, but thank you for the help.

luckysmack’s picture

I placed a brand new setting.php into my sites/site2.com directory, retried going to site2.com and it showed the same error (404, not authenticated). I tried pointing the domain directly to the root/myusername/site1.net directory and recieved a directory listing of all the folders (no files). You say the other directory needs an index file, but how am I to do that if that site2.com is symlinked to the main site1 folder? It seems to me like it should work. I have a fresh settings.php in the sites/site2 folder. Do I need a sites/site1.net folder as well?

cog.rusty’s picture

No index files are needed in the sites/sitename or sites/default directories. Just the one in Drupal's root. Those subdirectories are Drupal's internal business and the browser never goes there.

willgetitfixed’s picture

No indexes are needed and I agree with that, but I cannot get Drupal to start the install for myvirtualdomain.tld. I thought it was a routing problem and I started tracking the logs and realized I had another issue. It is not seeing or at least not reacting to the new settings.php file. I can put an index.html in the sites/myvirtualdomain.tld and I see it. What do I need to make Drupal act on the new settings.php??

This has worked repeatedly for sub.domain.tld, but I am missing something for the myvirtualdomain.tld.

Any assistance is appreciated.

cog.rusty’s picture

What is needed is:

- Copy a fresh unmodified settings.php file in the directory sites/myvirualdomain.tld, under Drupal.
- Make sure that the URL http://myvirtualdomain.tld leads to Drupal's main directory.
- Browse to http://myvirtualdomain.tld

luckysmack’s picture

I figured it out. In the settings for my domains there is an option to allow/disallow none or both letting users enter the www prefix. I changed them all to allow both www.site.com and site.com and viola! it works. I am pointing site2.com directly to my site1.net folder where drupal is installed. not even using the symlinks

Now I guess my next question is what is the best way to manage all the themes and mods for the different sites? should i put them all into sites/all/modules ? they will have different needs for mods. One will nedds ubercart but the others wont. another is more of a cummunity site. should i put all of the similar used mods there and specific ones ithe the individual sites/site.com/mod folder?

cog.rusty’s picture

Whether you put them in sites/all/modules and themes or in sites/sitename/modules and themes is completely up to you.

Some prefer to have the all modules together for easier uploading of updates.

However when you upload an updated module you also need to run update.php on each site separately, so some people strongly prefer to be able to control module updates on one site at a time, rather than having to update a module on all sites in the same day.

Others use a mixed approach, with only the very essential modules in sites/all (which may be CCK, Views, Tokens... it depends). In any case, putting ubercart and its dependent modules only in one site's modules may be wise.

Swift Arrow’s picture

I've gone through all the detailed instructions above, and following them, I've had some success.

Now, I have a problem. I'm toying around with Drupal installed locally on Web Developer WAMP server. I set up the domain names in localhosts.txt (for windows) and in Apache's virtualhosts config file. Then I set up different site folders in /sites.

The following I have been able to set up:
Address: Folder drupal accesses in /sites
drupal---------------default
domain1.tld----------domain1.tld
domain2.tld----------domain2.tld

The following only work if domain3.tld does not have it's own folder and settings.php file in /sites:

sub.domain3.tld------sub.domain3.tld
sub2.domain3.tld-----sub2.domain3.tld
If domain3.tld is also configured in drupal, then these two load that site, instead of the subdomain (!)

This I would really like to set up, but hasn't worked as follows:

domain1.tld/sub_site--sub_site.domain1.tld
- is this the right name for the folder? When I do it like this, I get drupal's "page not found" from domain 1.

Is there another way to do it? my host limits my domains and subdomains, that's why.

It would be great if drupal could serve one website at the address
domain1.tld/sub_site
and another from the address
domain1.tld
and yet another from:
sub.domain1.tld

Any ideas on setting this up?

Thanks in advance

cog.rusty’s picture

It does support those. There is a detailed explanation in the comments inside settings.php.

http://domain1.tld --> sites/domain1.tld/settings.php
http://sub.domain1.tld --> sites/sub.domain1.tld/settings.php
http://domain1.tld/sub_site --> sites/domain1.tld.sub_site/settings.php

I have no idea why your first example did not work. It should have worked.

Swift Arrow’s picture

Thanks Cog Rusty!!! That was really fast.

As it turns out, I've found another post at: http://drupal.org/node/30857 , which is exactly what I want.

I had read those things in settings.php According to bonobo, I have to set up a symlink in the drupal directory to point out, eg:

domain.tld/site2 needs:
symlink: inside the drupal install directory that points to the drupal install directory called site2
folder: /sites/domain.tld.site2
fresh settings.php in the folder

I guess this makes sense, since apache would first look inside public_html/drupal/site2 for the site, right?
I still have to try it though.

Thanks for your speedy reply!

johnhorning’s picture

Can all this apply to a case where you want multiple subdomains using a single database?

cog.rusty’s picture

If by "single database" you mean "same database tables", then it will be actually the same site, accessible using different domain names.

If by "single database" you mean that each site should have its own tables in the same database, then you can have completely different sites. (During installation there is an "advanced" option for specifying a prefix for each site's database tables.)

In either case, the answer is yes.

johnhorning’s picture

Thank you. Your first assumption is correct. I am trying to create a single site accessible via different subdomains. I have managed, with help from posts on this page, to set up a subdomain that points to my main site. What I really want, however, is for each subdomain to have it's own home page and it's own content with the possibility of accessing content from the rest of the site. I am planning to use Drupal's taxonomy features to group the data for each subdomain.

Before I go any further with this, I need to ask if what I've described above makes sense and can even be done. Is it possible to make one site look like many sites?

cog.rusty’s picture

For very simple differentiations between the sites, take a look at the variables at the end of the settings.php file of each site (even if they use the same database).

Additionally, for more interesting setups, you can differentiate content using taxonomy or organic groups, or you can create separate sites and use feeds and some node-making aggregator module. You can also differentiate menus and themes with the help of some module.

A few interesting modules which might help:

http://drupal.org/project/domain (Drupal 5 and 6)
http://drupal.org/project/virtual_site (Drupal 6)

http://drupal.org/project/crossite (Drupal 5)
http://drupal.org/project/og_sites (Drupal 5)
http://drupal.org/project/subdomain (Drupal 5)

http://drupal.org/project/domain_menu (Drupal 5)
http://drupal.org/project/sitecss (Drupal 5)
http://drupal.org/project/multisite_login (Drupal 5)
http://drupal.org/project/singlesignon (Drupal 5)

http://drupal.org/project/multisite_api (Drupal 5)
http://drupal.org/project/multisite_maintenance (Drupal 5)

I am sure I have missed some.

johnhorning’s picture

That's enough, thank you. Guess I need to do some homework now.

johnhorning’s picture

I need some clarification please. Do I need to delete the directory that was created by cpanel during the creation of a subdomain or not? If I delete it and issue a symlink command like this:
ln -s /home/usename/public_html/ /home/usename/public_html/subdomain
when I browse to the subdomain, it takes me to the main web site. If I don't delete the directory, I only get a listing of directories and files in the new subdomain directory, regardless of whether I issue the symlink command or not.

A couple more things: If I delete the new directory, where does settings.php go? And how does a new settings.php in the new directory get used if a symlink is redirecting traffic to the main web site, which has it's own settings.php.

This is all assuming, by the way, that I have just one drupal install and one database.

Advice on this would be greatly appreciated.

cog.rusty’s picture

You do need to delete the subdomain's directory. If you don't delete it, then the symlink is just not created, because the symlink is technically a kind of file which takes the directory's place.

When you haven't deleted the subdomain's directory, browsing to the subdomain just gets you that directory's contents. This is no use.
When you have the symink, then browsing to the subdomain you get Drupal's main directory. This is the whole point.

Drupal's directory is not just your main site. It is where Drupal's index.php is accessed, runs, and decides what site to serve. If you don't go there, Drupal never knows.

Drupal's settings.php files for all sites go under Drupal's sites directory (in your case, public_html/sites/sitename), named properly according to some rules which you can find in the comments inside settings.php. The purpose of this is to allow Drupal to compare the URL requested by the browser with these names and to serve the right site.

johnhorning’s picture

Thank you so much for the help. I thought it might be useful to share what I've learned. Here is what I did to install Drupal (v 5.7) under a subdomain (call it "subdomain") that is sharing the same database as the main site (call it "maindomain.com"):

  1. Create subdomain with your provider's CPanel.
  2. Use File Manager in CPanel (or other means) to delete the folder that was just created (should be under public_html and will have the same name as your new subdomain)
  3. Use Putty to connect to your server via SSH.
  4. Type this symlink command to forward requests for the new subdomain to the main site:
    ln -s /home/username/public_html/ home/username/public_html/subdomain
    (Change "username" to the user name you use to access CPanel. Note: if you can't get shell access to your site, try the php symlink() function described elsewhere on this page)
  5. Create a new directory under public_html/sites and name it "subdomain.maindomain.com"
  6. Open up the default settings.php file in any text editor (file is found in the \sites\default directory of your original drupal download files).
  7. Find the Base URL section and add this line:
    $base_url = 'http://subdomain.maindomain.com';
    (Note: No need to change anything in the Database Settings section if you are using the same database as the main web site.)
  8. Save the modified settings.php file somewhere and copy to the new directory you just created (under public_html/sites)
  9. Browse to http://subdomain.maindomain.com.
  10. You should see the Drupal "Database configuration" screen. Under "Advanced options", enter a "Table prefix" (ex: "subdomain")
  11. The rest is a repeat of your first Drupal installation.

:-)

johnhorning’s picture

After writing the previous post I began wondering if I really should specify a prefix for my tables. The ultimate goal is to be able to access all data from the main site while limiting what is available for the subdomain sites. What happens if I don't specify a table prefix? Will the subdomain site then use the same tables that the main site does? And what is the best strategy for achieving the goal of being able to access all data from the main site while limiting it for the sub-sites?

cog.rusty’s picture

Sharing all the tables (without prefixes) and sharing none (using prefixes) are the trivial cases for a multisite. Sharing only some of the tables is where it starts to become interesting, but it is not easy at all. It requires serious though and understanding.

If (for example) you have separate users, then user uid=15 of one site may be different from user uid=15 of the other site, and if you share content then the author/owner of a node may appear to be the same while he isn't.

That said, there are some well-tried practices of which tables to share and which to keep separate, such as this one.

http://drupal.org/node/147828

johnhorning’s picture

I need to make a correction to item number 4 above under subject "Success!". The correct command is:
ln -s /home/username/public_html/ /home/username/public_html/subdomain
(forgot a slash)

pmomidi’s picture

Is it possible to share user registration information across sub domains, even if they are using two different databases ?

For example :- If user registers with the main domain, is it possible for the same users to be allowed in to the sub domains with out further asking for user registration, since sub domains are having their own databases ?

cog.rusty’s picture

Different databases means different sites with different users. It is very difficult to keep them synchronized.

The only way is to have all sites' database tables in the same database, with a different prefix for each site, then share the tables related to users and sessions across all sites, and perhaps use the same $cookie_domain = 'example.com'; in all settings.php files.

In the handbook you can find a lot of details as well as modules which could help with this

http://drupal.org/node/147828

kding’s picture

Congrats first!

What exactly is "The rest is a repeat of your first Drupal installation."?

I installed my first drupal with Fantastico. In the installation process I was asked to enter a folder's name under where the drupal files would be placed. Now following your list, if the #11 step a new installation of drupal, what will be the folder it should be installed into? Thank you.

johnhorning’s picture

You don't install Drupal again. In step 10, you will see the same screen that you did when you initially installed Drupal. You're not actually installing it again, but you are going through a similar process in that you need to set preferences for the new subdomain you just set up. It's feels like a new site, but it is actually all on the same install and same database.

One important note - you don't set site information or theming the same way that you did in the original site if you're using Domain Access. You go to Domains in the Administer section and look on the Domain List tab. Click on the various links under Actions next to each domain or subdomain. And one other thing - I would not install all the Domain modules (particularly Domain Strict) unless you really need them. They can just cause confusion.

kding’s picture

thank you, rivulguy. I finally figured out with the help of this board. My new challenge is whether I should use one database, different prefix or multisites with multidatabases.

TonZijlstra’s picture

When using the same database, simply create/duplicate the drupal database tables with a different table prefix.
Then in stead making changes to the following line in the new settings.php file
$db_url = 'mysql://db-username:db-password@localhost/new-db-name';
edit the next one $db_prefix = 'newprefix';

Ton Zijlstra
blog: http://www.zylstra.org/blog

kding’s picture

Hi, I am new to this. I have had a site set up at http://keleding.com/drug. I want to go from there to build 2 more sites each for one class I am going to teach. For example I want to have a second site at http://keleding.com/epi. I don't need to use subdomain.

By reading the process of Multisite Installation, the first 3 steps, I feel like I can use Fantastico to install a second site at http://keleding.com/epi. Is this right?

# Using PHP MySQL or any other database application, create a database by the name "domain2"
# Grant full privileges to the database to the default user
# Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file ("database.sql").

So after having installed the second drupal should I follow the remaining steps such as

# Using cPanel or ftp, create a sub-directory in the (my first drupal site) "/sites" directory called "domain2.com" , and so on.

Do I interpret the process correctly? Please help. thank you!

cog.rusty’s picture

That was old. No "database.sql" file exists in the last two Drupal versions.

If you want to use Fantastico to install more sites, then actually you will be creating many separate Drupal sites and not a multisite. A multisite would use only one Drupal installation to access many domain names and many databases. But each time you use Fantastico you are getting an additional full Drupal installation with all its files.

kding’s picture

Thank you very much for response.

I have tested a second site. Now all connection seems right. The only problem is that I missed how to deal with the database. In my settings.php if I put this line only:

$db_url = 'mysql://db-username:db-password@localhost/first INSTALLATION db-name';

The subdomain url shows everything the same as the root installation. But if I add this following line in:

$db_prefix = 'newprefix';

I certainly get an error message because there is no such a db. So I guess I need to install a database. I have access to MySQL. But, my question is should I install a new drupal under the 'site/subdomain.com/ with a new database or should I only add a few of db tables with new prefix in the root installed db? Do I need to upload all or any drupal files into the ''site/subdomain.com'?

thanks again.

cog.rusty’s picture

If you have created your first site with Fantastico, make sure that drupal's main directory contains a file named install.php (Fantastico leaves out some drupal files). If install.php doesn't exist, you can't create a multisite anyway, and you will need a new full drupal installation for the second site.

Assuming that the installation script does exist and you can use a multisite, you should not enter your database information manually in you new site's settings.php, or else the installation of the new site won't work. Leave that for the installation script.

Create a sites/keleding.com.epi subdirectory. The name of this directory is important. It will tell drupal where to find the database for anyone visiting http://keleding.com/epi

The drupal version is also important. In Drupal 5, upload a fresh settings.php file from a drupal package of the exact same version into the sites/keleding.com.epi directory. In Drupal 6 don't upload anything at all.

After that, when you browse to your new site, http://keleding.com/epi, the installations script will run to create the tables in the database. You can specify either a new database or the same database but with a different prefix.

kding’s picture

Thanks very much. I followed your steps

1. Create a sites/keleding.com.epi subdirectory.
2. browse to the new site

Now i had a page not found. what I did not do:

I did not create a epi subdirectory in root
I do have install.php. so I did nothing
I have drupal 6.2 so I did not upload anything to sites/keleding.com.epi/.

cog.rusty’s picture

Yes, of course if nothing is in http://keleding.com/epi it is natural to get a "page not found". So, now you need to make the http://keleding.com/epi URL to lead to the directory where Drupal is installed. Then Drupal will notice the different URL and will use the new site's database.

To do this, some detail are needed:
- You need a symlink if it is a Linux server, or a junction if it is a Windows server. Which one is it?
- Do you have shell access so that you can type commands, or only FTP?

I assume that Drupal is installed in your public_html/drug directory (where the first site is), and not in your web root.

kding’s picture

Hi cog.rusty, it is me again.
I saw this post in this threat:

nope, you want a fresh settings.php untouched by you, or by drupal. just like you had when you downloaded drupal orginally for the first site.

by uploading a fresh settings.php drupal will find it and run install.php again. You will see the same screens you saw when you installed drupal the first time. you will enter your DB location DB username DB password and drupal will add it to settings.php as it orginally did. This time though you will enter the information for the 2nd DB (be it your husband or your daughter).

I guess I need to upload all drupal files into site/subdomain/ so this quoted action will work. Am I right?

cog.rusty’s picture

No, the whole point of a "multisite" is that you don't need a new drupal installation.

johnlutz’s picture

I have read most of this entire post and I think i have the basics of how this is supposed to work, but I just have one question:

I currently have a drupal site setup at domain1.com/drupal/

I would like other sites to link to the same drupal install (domain2.com, domain3.com, etc). I have one of these sites setup in cpanel as addon domain2.com and it automatically created the folder domain2. Once I knew it was going there, I removed that folder and created a folder in the drupal files - > domain1.com/drupal/sites/domain2.com

But this gave me a 404 Not Found error. I am assuming that when I type in domain2.com it is not hitting drupal because it is in the sub folder drupal instead of the root of domain1.com and so drupal isn't looking in its sites folder for that domain. Is that the case or is something else wrong. I haven't set up any symlinks as I wasn't sure if Drupal 6 needed it and I am not totally sure how it works anyway.

Question is if my drupal install can be in that drupal subfolder or if it needs to be in the root and if it can be, how do I set it up?

All your help is much appreciated. Thanks.

cog.rusty’s picture

You need symlinks. No Drupal version can change that.

Now domain2.com tries to go to a non-existend directory (the one which you deleted),and of course that causes a "404/nor found".

You need to create a symlink in the place of the deleted directory, which will lead to Drupal's main directory. So, Drupal's index.php file will run and will take care of bringing up the correct site.

If I understand correctly, your directories and your sites are like this:

/home/[blah]/public_http http://domain1.com (not Drupal)
/home/[blah]/public_http/drupal http://domain1.com/drupal  (Drupal installed and running)
/home/[blah]/public_http/domain2 http://domain2.com (you want a second Drupal site here)

If it is so, you need this:

ln -s /home/[blah]/public_http/drupal /home/[blah]/public_http/domain2

This command will create a symlink pointing to your drupal installation and having the place and name of the directory you deleted.

johnlutz’s picture

Thanks cog.rusty. So the symlink worked great. You are a saint as previously stated.

Got one more:

I am wanting domain2 and domain3, etc... to have a different sitename at the top of the site, but all of the content I want to be the same as domain1 and all the domains. Only things that will be different is the site name and look of the site.

Question is how do I do this? Do I need separate db's for all of these?

Thanks for all of your help in advance.

cog.rusty’s picture

A site's name and current theme is in the database, in the variables tables. This means that the site would need to share all tables except the variables table (in a way similar to http://drupal.org/node/147828).

But there is an easier solution if your needs are very simple. At the end of the settings.php file you can see an array of variables, where you can set the name and theme of a site (and many other things), no matter what the database says.

So, you can keep all the tables shared between the sites and differentiate them a bit using their settings.php files.

johnlutz’s picture

One final thing. I previously stated that I had the installation of drupal within domain1.com/drupal. I have tried to do a symlink for domain1.com to point to domain1.com/drupal but it isn't working like the subdomains were. Any suggestions on how to do this or if this can be done. Thanks for all your help.

This is what I tried but did not work. I keep getting the index of the site instead of drupal when I pull up domain1.com.

ln -s /home/domain1/public_html/drupal /home/domain1/public_html

Just so you know, I did create a folder inside of drupal/sites called domain1.com.

cog.rusty’s picture

It can't be done with symlinks.

In that command, the first path is the destination and the second path is the symlink's filename.

Now, if the symlink's filename is public_html, this implies that you have deleted the real public_html directory so that you can put the symlink in its place. But if a real public_html directory does not exist, how can it have a drupal subdirectory? So, your symlink was never created.

As Archimedes said at the Powerpoint presentation of his levers, "Give me a place to stand and I will move the Earth"

If what you want is domain1.com to lead to your drupal site, there are two ways to achieve it:

- Just install Drupal in public_html (simplest and cleanest)

- or use some .htaccess trick like in this discussion: http://drupal.org/node/144643

mkahn’s picture

Ive created module to link across subdomains, while staying on the same page, but there is an issue with publishing it. It will currently only work with path configured to another toplevel domain. The drupal core is excluding the subdomained link somewhere. Any help resolving this is greatly appreciated. I think this is a useful little nook for demoing cross subdomain functionality.

http://drupal.org/node/255894

Mark Kahn,
Droople Apprentice

lfhubcom’s picture

1. I want to add a video section to my sns but don"t you know my host don"t have ffmpeg so I was think about getting another host as a dedicated server...can multisite work with 2 diferent hosts?

2. I also want to add a auction site (phppro bid) to my site...I was planning on using my current host...will multisite work? I was told that I would have to write a module that would bridge them and that sounds scary...crossing my fingers there a better way...
Thanks in advance.

cog.rusty’s picture

First, it should be clear that when we talk about Drupal multisites here we mean something very specific: Running many Drupal sites from a single Drupal installation, not pulling-in content from other servers or running non-Drupal sites on the same server (which are both possible, but entirely different).

1. If you need ffmpeg and your current host does not have it, then the only practical solution is either to ask them to install it (possibly for a price) or to move to a host who does have it.

I don't believe a Drupal installation on one host can make use of ffmpeg running on another host. With some work you could pull content from another installation on the second host, but what's the point?

2. As I explained, a multisite is for reusing a Drupal installation to run multiple Drupal sites. Running a non-Drupal site with PHP Pro Bid on another domain or subdomain of the same server is perfectly possible and Drupal won't have anything to do with that.

The only thing you might want to bridge is the users. You could take ideas for how this can be done from several existing modules, for example phpbbforum, smfforum, gallery2 etc.

lfhubcom’s picture

thank you for replying so quickly. You were a major help.

georgelai’s picture

I have read your thread...very interesting.

I have a related question: I wish to create many websites with related theme, and am concerned that the database will blossom out of control very quickly. I thought about separating the mysql database into a user database, and regional databases (for example, north, south, east, and west). I found a command to change databases in php code:

for example, with the North database, you can do this by changing the $db_url in the settings.php file to:

$db_url['default'] = 'mysql://user:password@localhost/drupal5';
$db_url['north'] = 'mysql://user:password@localhost/northdb';

and in your module code:

// Get info from movie database
db_set_active('north');
$result = db_query("SELECT * FROM comments WHERE uid = %d", $user->uid);

// Switch back to default connection when finished.
db_set_active('default');

I would still like to use ONE Drupal code for the multiple sites. When the user logs in, my code would check the default location of the user, and change the regional database accordingly (North, South, East, West), and access that database using the above code. However, the user can jump to another region, if he so chooses; this would change his default location, and the default database to use.

That is why I wanted to keep the databases separate.

Is this possible, or am I asking for trouble by doing this?

The other, more standard way, to do this is: if I create a multisite with different tables (prefix) representing the different regions (eg, North_event, South_event), will MySQL be able to handle query thousands if not millions of events in the North_event table quickly?

And backing up such a database would be a bear to do, right?

Thanks for any help you can provide.

George

doudou’s picture

I tired the multisite function by using all the information on this page. For addon or parked domains it worked great. However I am having problems doing the same for subdomain.

First my drupal installation is under public_html/demo1/

Then I created a subdomain called site1.mysite.com, I deleted the subfolder site1 and created a symlink:

symlink( "./demo1", "./site1" );

I also created demo1/sites/site1.mysite.com/settings.php and configured the database access, but left everything else the same.

For some reason when I goto site1.mysite.com I am getting a server not found error. I've called the hosting support and they verified that the symlink is working.

I am not sure what I am doing wrong, can someone help?

Thanks

cog.rusty’s picture

Since the error is "server not found" and not "url not found on this server", it is probably a DNS problem with your subdomain's setup.

But sometimes it is caused by something on the browser side. Try a different browser or a different computer to see if it persists.

Have you added any rewrites in your .htaccess file which have to do with "www." or subdomain prefixes?

doudou’s picture

Thanks for your help. You got it right, it was a problem with with my DNS, the hosting support fixed it. I did nothing wrong!

lakermark’s picture

Thank you for taking the time to write this out and help everyone out. I recommend this article to EVERYONE.

seanchiggins’s picture

Thank you for your article. It helped me migrate from two instances of Drupal to multisite Drupal see my notes at http://www.systura.com/node/5.

hiflyer’s picture

This all makes sense to me except for:
"# Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file ("database.sql")."

Can someone spell that out in steps a little better for me? I'm a serious novice at MySql. I already have a Drupal site created and am now creating a new one. How do I create default tables and data in my new database for the sub if my original Drupal installation has already modified the database?

cog.rusty’s picture

That was very old (Drupal 4.7). See the answer to http://drupal.org/node/107347#comment-270336 above.

If you want to install a second site in the same database, the installer has an "Advanced" section where you can specify a table name prefix while installing the second site..

darumaki’s picture

Can someone explain the difference between single database and multiple database. In my experience one database is just having several databases all under one roof via different prefix, where as multi-database is having separate databases. Is there an major benefit to having all your eggs in one basket ?

Is it done primarily to share certain tables ? I was always under the impression that having multiple databases inside one database makes it slower, it certainly makes it more difficult to find things.

I have a difficult time calling it a single database because really it's multiple databases inside one. Am I understanding it correctly ?

cog.rusty’s picture

You are right. There is no benefit in putting many sites in the same database with different table prefixes. Separate databased are better for maintenance and (probably) for performance.

But a single database with different prefixes is necessary when:

a) Your host gives you only one database, or only few databases which you need to use for other things. This is rare, because in our days such a host should be out of business.

b) You need to share some Drupal database tables between different sites, which can be done only using one database with different prefixes, controlled from a $db_prefix array.

This is a Drupal limitation. Maybe one day someone will come up with code to do this using the $db_url array, which now only supports switching to one database at a time.

Seneschall’s picture

I asked here about a year ago and got some great help. But for the life of me I can't remember how I did it. I'm trying a 2nd multi-site setup, and it's not working.

This time it's Drupal 5.7.

I have www.domain.com, which is local/home/domain.com/
subdomain.domain.com, which is local/home/subdomain.domain.com/

According to putty, when I look at the files for the symlink (subdomain.domain.com), I can see all the drupal files in (domain.com/). So that means it SHOULD BE pointing to the right place. Am I right?

I double-checked on my old working symlinks from the other multisite, and they do the same thing.

Without modifying ANYTHING on the settings, I should AT LEAST be getting my main domain, right?

What did I forget?

Cheers!

cog.rusty’s picture

What exactly happens when you browse to http://subdomain.domain.com?

If your new symlink works, and you have a new database ready, then the next thing you need to do is:
1. Create a new subdirectory under sites, named exactly subdomain.domain.com
2. In this new sites/subdomain.domain.com directory, copy a fresh settings.php file from a drupal package (found under sites/default). Don't use the one that you already have under sites/default on your site.
3. Browse to http://subdomain.domain.com to start the installer for the new site.

About your question, without modifying anything on the settings, you should get the main site if and only if your main site's settings file is in sites/default and you haven't created a sites/subdomain.domain.com directory.

bazzly’s picture

Quick questions

Using phpMyAdmin, create the tables and default data in your database by suitably modifying the drupal database file ("database.sql").

Create what tables and default data? Does this have to do with the prefix, if its a shared database?

Copy the /sites/default/settings.php to the new directory /sites/domain2.com/settings.php

So all I need to copy over is the settings.php to the /sites/domain2.com/settings.php? Nothing else NEEDS to be in there?

vm’s picture

This thread was orginally about Drupal 4.7.x since then there is an auto installer in Drupal starting with 5.x. so you don't do anything manually to the database or a .mysql file.

So all I need to copy over is the settings.php to the /sites/domain2.com/settings.php? Nothing else NEEDS to be in there?

yes, a brand spanking new settings.php file is the only file that goes in this folder.

what happens is your browser calls domain2.com and domain2.com searchs the sites folder and finds a match and uses that settings.php to connect to the database.

if you have any more questions I highly suggest starting a new thread or finding one that isn't so old and sitting in a deprecated folder. Especially when the thread is about a set up on a version of drupal that is no longer supported.

paolorizzi78’s picture

Dear coders,

I already did a multi site installation and everything is working fine except ONE thing!!

I used for the 2 different domain installation the same table for the users "users" and I assume that if I'm in domain1.com and I login like admin I have all the admin options availabe (and it is like that!! everything works!!)

the problem comes out when I launch the domain2.com and I try to login like admin... and well, seems that the system doesn't reconize me like admin, I do not have access to any of the administration pages.

Did you experienced somehting similar?

I would really appreciate your help as I'm on this problem fro few days and I can't find a solution.

Thank you to everyone!!!

Seneschall’s picture

Got the symlinks down. Here's what I want to do...

Between the two, I want the user of site One.com to be also able to use site two.com.
The ed-classifieds should be the same for both sites. (submit on site one, it's viewable on site two)
The events calendar should be the same on both sites (events.module)

Possibly the SMFforum module, too, as They'll both use the same non-drupal forum (simple machines).

That's it. Just those. Can't think of anything more that should be the same.

Is this realistic? If so, what do I do before installing site 2 to ensure this? Using Drupal 6.10.

Seneschall’s picture

from settings.php on main site (sites/default/settings.php

$db_url = 'mysql://dbusername:dbuserPass@localhost/maindatabase';
$db_prefix = 'main_';

from settings.php on new site (sites/newsite.com/settings.php

$db_url = 'mysql://dbusername:dbuserPass@localhost/newdatabase';
$db_prefix = array(
'default' => '',
'authmap' => 'maindatabase.',
'profile_fields' => 'maindatabase.',
'profile_values' => 'maindatabase.',
'role' => 'maindatabase.',
'sessions' => 'maindatabase.',
'users' => 'maindatabase.',
);

newsite isn't coming up. Gotta be a mistake in here somewhere that I just can't find.

bzhu’s picture

In Apache Virtual Host configuration, you may use the same doc directory for different virtual hosts (domain names). It is not necessary to create symbolic links at all. For example, if you want park three domains such as "domainname1.tld", "domainname2.tld" and "subdomain.domainname.tld" sharing the same Drupal codes located at /home/username/public_html, just add the following virtual hosts in Apache_config_path/extra/httpd-vhosts.conf:

<VirtualHost *:80>
    ServerAdmin webmaster@domainname1.tld
    DocumentRoot "/home/username/public_html"
    ServerName domainname1.tld
    ServerAlias www.domainname1.tld
    ErrorLog "logs/domainname1-error_log"
    CustomLog "logs/domainname1-access_log" common
#
<Directory "/home/username/public_html">
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@domainname2.tld
    DocumentRoot "/home/username/public_html"
    ServerName domainname2.tld
    ServerAlias www.domainname2.tld
    ErrorLog "logs/domainname1-error_log"
    CustomLog "logs/domainname1-access_log" common
#
<Directory "/home/username/public_html">
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@sudomain.domainname.tld
    DocumentRoot "/home/username/public_html"
    ServerName subdomain.domainname.tld
    ErrorLog "logs/subdomain-error_log"
    CustomLog "logs/subdomain-access_log" common
#
<Directory "/home/username/public_html">
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
</VirtualHost>

You only need symbolic links if you use sub-directories as multi sites, for example, if you want to set up two sites like http://domainname.tld/site1 and http://domainname.tld/site2, then you need to create two symbolic links under your default site directory:

  cd /home/username/public_html
  ln -s ../public_html site1     (or: ln -s /home/username/public_html site1)
  ln -s ../public_html site2     (or: ln -s /home/username/public_html site2)
kelvinc’s picture

If I have 3 URL like xxx.com, xxx.com.nz and www.xxx.com, do I need to create 3 sub-folders in sites?

Edited by silverwing - www. xxx .com actually leads to an adult site!

cog.rusty’s picture

Only if these are different sites, with different databases specified in different settings.php files.

If they are all the same site, then sites/default or sites/xxx.com can cover them all (see the comments inside the settings.php file).

kelvinc’s picture

It's working but not sure if I did properly.

In apache conf.d, all sites are pointed to symbol links like:
DocumentRoot /var/www/html/site1.com
ServerName site1.com
DocumentRoot /var/www/html/site1.com
ServerName site1Alias
DocumentRoot /var/www/html/site2.com
ServerName site2.com

site1.com and site2.com are both symbol links, which point to /var/www/html/drupal (code base).
And there are 2 sub-directories created as sites/site1.com and sites/site2.com, which point to different database.

To get site1Alias working, I add a symbol link site1Alias in sites/, which points to site1.com.

*******************************************************************
This looks a bit too complex.
So I tried to remove all the symbol links in /var/www/html and point all the URL to /var/www/html/drupal in apache conf setting, but failed to work.
Any thoughts?

cog.rusty’s picture

The answer depends on how it failed to work.

- If your different URLs give you a "not found" page from apache then the problem is in apache's conf file (did you restart apache?)

- If your different URLs work, but they give you the wrong drupal site, then it is a drupal configuration problem. What problem exactly... depends on the details of the failure.

kelvinc’s picture

It brings me to "default" site.

cog.rusty’s picture

Check to make sure that:

- when you browse to othersite.com that URL is preserved in your browser's address bar and does not change to something else (for example, because of some apache rewrite).

- the name of the directory is exactly sites/othersite.com/ (or a proper match), case-sensitive.

- the settings.php file under sites/othersite.com/ is different from the one under sites/default/ and does not contain the same database info as the default site.

kelvinc’s picture

Just took a try again and it worked~
Thank you mate

However a new issue comes up is when I log into site1, I dont get logged into www.site1.com.
They are same site and point to the same database.
I didn't use name alias but add one symbol link under sites/ like www.site1.com->site1.

cog.rusty’s picture

Login depends on the domain name (because cookies depend on the domain name). It doesn't matter if they are the same site or not.

If the domain names of two sites are the same (for example www.site1.com and blog.site1.com) it is possible to make them use the same cookie domain (site1.com) in their settings.php files. But if the domain names of the two sites are different, then shared login is not easy with conventional methods.

See also this module: http://drupal.org/project/sso

kelvinc’s picture

Thank you
I understand more now

jgriffis’s picture

I am trying to set up multiple sites for an intranet, using an IP address (no domain name) and having multiple sites in subfolders that mirror an organizational structure (e.g. 13.9.333.12, 13.9.333.12/division1 , 13.9.333.12/division2) .

1. Can you create multiple sites without a domain name?
2. If so, what do you name the subfolders in the sites directory?

cog.rusty’s picture

You can. The names of the sites/subdirectories are (surprise)
sites/13.9.333.12
sites/13.9.333.12.division1
sites/13.9.333.12.division2

or even

sites/13.9.333.12.8080
if you use a different port in http://13.9.333.12:8080

There are many examples in the INSTALL.txt file which explain a lot.

dmcdenissen’s picture

Hope one of you can help me, I'm currently testing some things in drupal6 concerning multisite. I have a server on my network with MAMP where I installed a multisite drupal install all works fine and I get how it works. My current install is:

sites/site1.example.dev/ --> can view them on my imac by going to : http://site1.example.dev:8888/ (I configured my hosts to let site1.example.dev goto the server IP)
sites/site2.example.dev/ --> same as above but then I can view it on: http://site2.example.dev:8888/

All works well. now I was reading about that I could make an other site in a multisite by making the following directory with settings.php and all in it:

sites/site1.example.dev.anothersite/

Then it should be visible by going to: http://site1.example.dev:8888/anothersite

but it isn't, can anybody help me... Thanks alot been spending hours on searching how its done but I can't find anything...

UPDATE

also tried to to rename the directories to:

sites/8888.site1.example.dev/ WORKS ! -> http://site1.example.dev:8888/
sites/8888.site2.example.dev/ WORKS ! -> http://site2.example.dev:8888/
sites/8888.site1.example.dev.anothersite/ DOESN'T WORK -> http://site1.example.dev:8888/anothersite/

I also added $base_url = 'http://site1.example.dev:8888/anothersite'; to the last ones settings

All doesn't work

cog.rusty’s picture

The problem is that when you browse to http://site1.example.dev:8888/anothersite the web server looks for a non-existent "anothersite" subdirectory under Drupal's directory, and Drupal never gets the request.

The easiest way is to create a symlink named "anothersite" under drupal, which will point back to drupal.

cd ~/drupaldir
ln -s . anothersite

Another way is to create an apache alias in the site1.example.dev vhost, which associates an URL path with a filesystem directory.

Alias /anothersite  ~/drupaldir

The last one may work as is or may need something more, depending on whether you need a RewriteBase setting.

dmcdenissen’s picture

Thanks for your reply, Still have 2 questions then ?

1- Isn't it possible without an alias or symlink ?
2- And in the path where the alias / symlink goes to do I need to setup a new drupal install or just the same as the other directories I got, so the same content as in site1.example.dev ?

Thanks again, been searching the web for hours to solve my problem I only didn't realise that I had to make a symlink, I was looking for a solution without symlinking ...