I have seen people having trouble install multiple sites from a single codebase.
That is why I have posted this.
Pros of a multisite installation:
•Less room taken
Cons of a multisite installation:
•You need certain features not all hosts have

I hope this helps.

Hosting requirments:
SSH access
FTP access

Directions:
1. If you don't have an FTP client, get one, or use the one you have. For Mac OS X 10.3.9 or later, use Cyberduck, and you see the website at http://www.cyberduck.ch, and download it at http://cyberduck.ch/Cyberduck-2.5.5.dmg. For Windows, use Firezilla, at http://firezilla.scourceforge.net, and downloadable at http://prdownloads.sourceforge.net/filezilla/FileZilla_2_2_19.zip?download.
2. With your FTP client, connect to the FTP server.
3. Install Drupal in the main directory of your site. In this example, we'll say this is in the main directory, or /main. For those of you that don't know, / seperates directories, and the directory / is the directory that you first see when you log in to FTP, also called root.
4. Using whatever service you host has (e.g. CPanel, 1&1 Control panel, ect.) create the subdomain you want(In 1&1, you will need to change the destination.
5. Using your FTP client, look for the folder that your host created. Here we will assume it is /subdir
6. Open up your shell program. On Mac OS X, it is the Terminal. I'm not quite sure as to wat it is on Windows, because I don't use it, but I'll find out.
7. Into the shell, type ssh <i>your ssh username</i>@<i>your web url (e.g. example.com)</i> Then press the key enter.
8. You will then be asked to type in your password, so type in the password for your ssh account
9. Now type in ln -s /main <i>(or the folder that your Drupal installation is in)</i> /subdir <i>(or the folder that your subdomain is in)</i>
10. Now in the Drupal installation, copy the settings.php file in sites/default to sites/your subdomain.your domain name.com
Now you are finished!!
I hope I made the instructions clear and easy.

Please post comments saying if I got anything wrong.

Comments

ToddZ-1’s picture

"multiple sites from a single codebase" -- I think I see what you're after here, but for us newer types, could you clarify what we end up with? Is it to have multiple sites with individual setup & configuration, but only one location to install new modules and upgrade to new versions?

dmitrig01’s picture

What this is for is if you want to install multiple sites, but keep all the module/themes/translations/ect. in the same place.
You can have the sites be completely diffrent by editing the settings.php file.

::::::::::::::::::::::::::
My opinion of drupal:
The best of the best
What I have to say about drupal:

Drupal, my hero

::::::::::::::::::::::::::

ToddZ-1’s picture

That's what I was hoping for!

jaku ayala’s picture

How do you know that your other sites will retreive content from your codebase? I mean, what if another drupal webmaster made his own settings file, pointing your domain to his own installation?

dmitrig01’s picture

>How do you know that your other sites will retreive content from your codebase?
You can check in includes/bootstrap.inc, and if you followed the instructions, it should work.
>I mean, what if another drupal webmaster made his own settings file, pointing your domain to his own installation?
He coudn't do that because he would need to have the same FTP account as you.

::::::::::::::::::::::::::
My opinion of drupal:
The best of the best
What I have to say about drupal:

Drupal, my hero

::::::::::::::::::::::::::

dmitrig01’s picture

Please ommit the <i>s and the </i>s

::::::::::::::::::::::::::
My opinion of drupal:
The best of the best
What I have to say about drupal:

Drupal, my hero

::::::::::::::::::::::::::

zanyland’s picture

I'm brand-new to Drupal, but a lot of people have recommended it. I'm wanting to set up several sites where the site owners can go in and put their own content. However, every site would also have common elements that would be the same on each of the sites in my "family" (in this case, games).

If I'm understanding you correctly, setting up Drupal in this manner would allow site_01.com, site_02.com and site_03.com to each have their own home page, but to also include the same game pages on each site. Is that correct?

Thanks.
-zany

dmitrig01’s picture

Not exactly. It would work like all the sites would run on the same code, but the could be totaliy diffrent (e.g. diffrent themes/modules/translations/databases/everything else, exept the core includes)

::::::::::::::::::::::::::
My opinion of drupal:
The best of the best
What I have to say about drupal:

Drupal, my hero

::::::::::::::::::::::::::

radref’s picture

Will this work for multiple subdirectories or only with multiple sites with distict ip addresses? In other words, can I set it up at

/www/drupal/site1,
/www/drupal/site2,
/www/drupal/site3

I'd like to use it for multiple distinct projects within a large organization, but don't want to share modules, themes etc.

magnusprime’s picture

So, if I add new settings.php files to the proper folder under /sites, then the result is multiple "sites" from one "core install".

EX: site1.noob.com and site2.noob.com would have under the sites folder, their own settings.php file. This way, all modules that are available are available across both installs. This does not mean that they both have the same modules active, or that they share a DB. Just that they share common modules and themes.

Am I correct in this?

Thanks

ceardach’s picture

You're correct.

Each separate settings.php file can be set to access a wholly different database, or the same database with different prefixes, or the same database with some shared tables with others that are not.

If you have wholly different databases, the advantage to having a multi-site would be sharing the same themes and modules, allowing you to make updates to them once, instead of for each site.

If, for example, you want a unique change to a module or theme for a site, then you could create a modules and/or themes folder under it's respective "sites" folder, and place the unique modules and themes there. They will then only show up for that site.

avolve’s picture

my issue is a little different, and i have given it a bit of thought - and again since re-reading this a few times...

see: http://drupal.org/node/59012

I have drupal installed in site.com/drupal and want to use automatic redirect of the webfolder to site.com (dreamhost).

if i was to use the command line to create a symbolic link (symlink: ln -s) - not sure if it will work as i am using subfolders and not subdirectories? maybe it will?

Do i create the following file

sites/site.com/drupal/settings.php

in the drupal install?

i am a little hesitant in messing around with the command line if i am not 100% sure it will work.

avolve designs | ethical by design

benthere’s picture

If your host allows you to point multiple domains/subdomains at the same directory, you can leave out the ln -s stuff. Such as DreamHost and probably Site5. Those instructions work well for cpanel-managed sites though.

Also, a good Windows ssh client is PuTTY.

-- Ben // profilefx.com

bosx’s picture

Ok, so you have domain-a.com for default install, and say you want another drupal site on domain-c.com and domain-c.com

Both separate themes and possibly different modules (but both share same default modules as domain-a.com (but can be enabled/disabled on a per site basis in admin -- as usual, and share same themes as domain-a.com (but can be enabled/disabled on a per site basis in admin).

Additionally new themes/modules can be installed on B and C that have nothing to do with A.

Ok so domain-a.com contains ALL of the drupal install files, and a /sites directory that contains /default -- which contains the settings.php info for domain-a.com

Now you create new directories within /sites for each domain you want to host a drupal site on, from same code as domain-a.com These can be separate actual Domain.coms or sub-direcorites of domain-a.com (but in this example I want to know about separate full DOMAIN.coms (separate accounts hosted on same server with separate FTP, email, etc.).

So in this case you would add:

domain-b.com/settings.php
domain-b.com/themes/theme_b (as well as any additional)
domain-b.com/modules/module_b (as well as any additional)

The only requirement though is the domain-b.com/settings.php file

domain-c.com/settings.php
domain-c.com/themes/theme_c (as well as any additional)
domain-c.com/modules/module_c (as well as any additional)

The only requirement though is the domain-c.com/settings.php file

Now, this may sound crazy, but no where in the DRUPAL install file or ANYwhere I've seen on any forum/post in Drupal.org, someone clearly explain how does site domain-b.com and domain-c.com know how to access the the code in domain-a.com?

Yes, some say it has to be done with some kind of symbolic link.

I had to figure it out myself, by "pointing" the public directory of domain-b.com and domain-c.com to the domain-a.com in apache.conf file.

I'm sure the same thing can be done with symbolic link, but why doesn't install file say exactly what is necessary and how to complete a multisite install -- or point you to exact place to find a straightforward outline?

Even though it may be a fairly simple process, it would be nice of someone to clearly explain every aspect of it in a tutorial for the layman.

Reminder, not everyone who uses Drupal is a technical geek. And i have nothing against geeks! I hope to be one some day.

Eddt’s picture

I've got two domain setup with my hosting. domain1.com has drupal installed at the root and is running fine. domain2.com is actually setup as an alias on the server that points to a subdomain - domain2.domain1.com. The domain2.com name resolves correctly and goes to the current page in the /root/domain2 folder (where /root is domain1).

I've done all the steps for multisite as drupal states, and have a seperate DB setup for the drupal I want to install on domain2.com - but for the life of me, I can't see how to get domain2.com to go BACK out into the root for the files it needs!

I know its an htaccess thingy that will do it for me, but I've no clue now as to what to do!

Success’s picture

"Now, this may sound crazy, but no where in the DRUPAL install file or ANYwhere I've seen on any forum/post in Drupal.org, someone clearly explain how does site domain-b.com and domain-c.com know how to access the the code in domain-a.com?"

I am also confused about this.

ceardach’s picture

As long as each domain is pointing to the same folder on your server, Drupal will handle the rest.

The problem is... how do you get the domains to point to the same folder on your server? And that is not an easy question to answer.

Every single host I have encountered uses a different process. With one, I have to mess around with Virtual Hosts. With another, I can just set up a symbolic link. With yet another, I simply set up an "add on" domain. The only way Drupal could solve the inconsistency problem is if people from each host wrote up a guide for their host. Not too easy to arrange.

Basically, what people are going to have to do is go to their host, look around their FAQ or knowledge base, or submit a support request to find out how to point multiple domains to the same folder.

TomSkelf’s picture

Hello!

Thanks for these tips, however I'm still having a few problems...

My main Drupal installation is in a "/home/tom/html/drupal" folder. I was able to make another folder point to the same Drupal installation by:

- creating a sub-directory: "/home/tom/html/drupal/sites/newsite"
- adding a "settings.php" file to it
- creating a symbolic link from "/home/tom/html/newsite" to "/home/tom/html/drupal"

However, when I view the new site, I get exactly the same content as the defaul site. Instead of this, I want *entirely different* content on the new site. In other words, I want to run two different sites with no common content on the same web-server using one installation of Druapl. Is this possible? If so, please could somebody explain how I can do so?

I tried changing the "settings.php" file for the new site so that it includes a database prefix, but an error occurs because tables with those names do no exist. How do I create Drupal database tables with a table prefix? The installation instructions don't seem to explain it.

Many thanks for any suggestions.

Cheers,
Tom

SomebodySysop’s picture

I did the same thing you did, except instead of link to the /drupal site, I went into Apache httpd.conf and created a virtual site "newsite" to put to /drupal directory.

Same thing as you -- I get the same content as in the default site.

Same as you , how do I do this to get a totally clean site to add totally new content to?

Thanks!

-ron

mlncn’s picture

1. Take the database/database.4.1.mysql (or 4.0) that you used to install the original database.

2. Find and replace all instances of "CREATE TABLE " (the trailing space is important) with "CREATE TABLE prefix_" (with NO trailing space.)

3. Find and replace all instances of "INSERT INTO " with "INSERT INTO prefix_"

4. use the database.4.X.mysql file as you did in setting up the first Drupal database!

... Four steps is pretty easy... but you still have the option to (one step) hire me!

~ben http://bemweb.com/contact/

benjamin melançon, human being

world's poorest philanthropist

person who gives a damn, http://pwgd.org/

web site programmer/designer & digital photographer, now in the
Agaric Design Collective
http://agaricdesign.com/

fund for authentic journalism, http://authenticjournalism.org/ ... etc. ...

benjamin, Agaric

ceardach’s picture

It sounds as though your two sites are referring to the same database. The core files "run" your site, while the database contains all of the content and settings. If you want unique sites, then create a separate database and refer to that in your settings.php file.

The usage of prefixes are for those who are limited in the number of databases they can create, or for those who want to share tables across separate sites (for example, sharing all users).

But in order to use prefixes, you'll have to manually add the prefix to the tables yourself.

kickn’s picture

I think you might be able to assume that because each site has its own DB connection that the content is COMPLETELY different.

walterbyrd’s picture

If so, then the original article completely left out a **HUGE** step.

Do I need to edit the settings.php file in the newly created: /sites/subdomain.domain.com to point to the new database?

Can anybody explain on a conceptual level what is going on? Does drupal sense the domain name and know which settings.php file to read?

The way I understand the original article, you would simply have one domain name pointing to another.

Rok Žlender’s picture

Do I need to edit the settings.php file in the newly created: /sites/subdomain.domain.com to point to the new database?

Yes if you want to have different content on your two sites you need to configure each settings.php files so that they point to their own databases. You can find some information here http://drupal.org/node/43816.

Can anybody explain on a conceptual level what is going on? Does drupal sense the domain name and know which settings.php file to read?

Drupals bootstrap procedure looks into $_SERVER['HTTP_HOST'] to see from which address your site is accessed and according to this it does a bit of magic and loads the appropriate settings.php file, modules and themes.

So basically you can have completely separete sites with different domain names on one apache server without virtual hosts and with one Drupal base files.

Success’s picture

"So basically you can have completely separete sites with different domain names on one apache server without virtual hosts and with one Drupal base files."

Can you explain in detail how to configure this?

Thanks a lot.

schwa’s picture

You want: "completely separate sites with different domain names on one apache server without virtual hosts and with one Drupal base files." The plan: create a new Drupal at http://www.mysite.com/newsite that functions off the codebase of www.mysite.com/drupal (the new Drupal can share themes and modules with the original one) but no user could ever tell that this is the case; they function like two completely different sites with different log-ins, themes, etc.
--
Assuming you have a functional Drupal site at this address: http://www.mysite.com/drupal
Assuming you have ftp and shell (SSH) access to your server.
Assuming you have some way to create/manipulate mySQL databases on that server (aka PHPmyAdmin)
--

Create a new Drupal mySQL database (either a brand-new one, or a second set of tables with a prefix on an old one, as described here.)

Create a user who has privileges to this database or assign local privileges to an existing user.

.

FTP to your server.

In www.mysite.com/drupal/sites create a new folder named www.mysite.com.newsite

Make a copy of the settings.php file from mysite/drupal/sites/default.

Edit this new settings.php file to reflect your new database and user, and put it into the www.mysite.com.newsite folder

Create a new folder in www.mysite.com.newsite called files. If you will be doing a lot of customization, also create folders called themes and modules in www.mysite.com.newsite - Drupal will look here first before using the global ones from www.mysite.com/drupal.

.

Now, SSH to www.mysite.com (using Terminal on Mac or puTTY on Windows) with this command:
ssh www.mysite.com

Log in to the server with name/passwd.

Assuming that your drupal at www.mysite.com/drupal is in htdocs (check with FTP to see exactly where it lives), go there with this command:
cd /usr/local/apache/htdocs

Your cursor prompt should now say [yourname@mysite htdocs]

Now create a symbolic link to newsite from www.mysite.com/drupal with this command:
ln -s drupal newsite
where drupal=your original drupal folder name and newsite=your new site folder name.

You won't get any confirmation, just a new cursor prompt. Log off or first open a browser to see if it worked.

.

In a browser, navigate to www.mysite.com/newsite and register yourself as first user.

In administer > settings > File system settings, make sure the file path is set to:
sites/www.mysite.com.newsite/files. This makes sure that all your media content will be stored in one discrete place within your subsite (not in the global files folder on www.mysite.com/drupal) should you ever archive or move this drupal site elsewhere.

*posted with no guarantee or particular techie skills; this did work for me*

walterbyrd’s picture

1) I asked by web-hoster to create some sub-domains (I can not do this directly). The web-hoster told me that the sub-domains were created. How do I know? When I try to go to sub1.domain.com I get this error message: "The requested URL / was not found on this server." does that mean the sub-domain was not created?

2) What is the difference between domain.com/sub1 and sub1.domain.com?

3) Main main drupal site is in a sub-directory off public_html. When I go to domain.com, I am automatically redirected to domain.com/main. So, in my case, what do I link to what? Assuming sub1.domain.com was actually created, do I link public_html/main/sub1 to sub1.domain.com, or what?

marcoBauli’s picture

1: you first need to create a /sub1.domain.com folder in the /sites directory and use a settings.php file there to set up your subdomain.

2: domain.com/sub1 is a subdirectory of domain.com.
sub1.domain.com is a completely separated site for search engines, and depending on your database tables settings it can share contents with domain.com or be unique in almost everything.

3: just redirect to the core drupal install and make sure you have well tweaked point 1. Drupal will automagically handle the subdomain for you, enjoy!

capitaine’s picture

Am using Drupal 5 beta 2 and can't set up multiple sites

This is what I have:

sites/default/settings.php
sites/www.newsite.com/settings.php

and I ran ln -s drupalfolder newsitefolder through SSH

and it didn't work. I also tried ln -s drupalfolder/ newsitefolder/ (with trailing /) and it said ln: newsitefolder//: File exists

But when I go to www.newsite.com, I do not see a Drupal install....

Any help please? I can't see why its not working...!??

schwa’s picture

@capitaine: this might be where you've gone wrong:

sites/www.newsite.com/settings.php

It should be:

www.oldsite.com/drupal/sites/www.oldsite.com.newsite/settings.php

I.e., put the newsite name after the .com of the oldsite in the new site folder name. Then the

ln -s drupalfolder newsitefolder command should work. :)

capitaine’s picture

Let me clarify.. I have www.domainabc.info as the main Drupal install. I then have www.domainxyz.org as the new Drupal site

On my server the folders are called domainabc and domainxyz

So are you saying I should have sites/www.domainabc.info.www.domainxyz.org/settings.php or do you mean sites/www.domainabc.info.domainxyz/settings.php?

I tried both but its not working - it seems I am doing something fundamentally wrong....?? Every time I do ln -s domainabc domainxyz it tells me ln: domainxyz/domainabc: File exists

schwa’s picture

Ah! I see what you're after - unfortunately, you can't make subsites with a brand-new domain name; they have to be subs of the main domain, otherwise you'd have to buy/register a whole new domain. (Then you could just put a Drupal on each and be done with it.)

What you can do when running just one domain, though, is create subsites like www.domain.org/abc and www.domain.org/xyz. These can operate as fully independent Drupals with no whiff of interaction or hint that they're connected behind the scenes, but they will share the same base code. That's where my instructions above come in.

So you'd have for instance three different drupal instances with the following directory setup, one at www.domain.org, one at www.domain.org/abc, and one at www.domain.org/xyz :

www.domain.org/sites/default/settings.php
www.domain.org/sites/www.domain.org.abc/settings.php
www.domain.org/sites/www.domain.org.xyz/settings.php

Hope that helps --

capitaine’s picture

Oh. But I have bought a new domain... as my new site can't be a sub. But all my sites sit on the same server.... I thought you could do it like this? (otherwise I have to maintain separate codebases.... the Drupal install instructions seem to imply that you can have separate websites sharing the same codebase....)

Even the title of this topic is incorrect, if you can't run multiple websites (distinct domains sitting off one webserver) with one codebase.... essentially its referring to sub-domains

Thx for your help btw

schwa’s picture

hey there,

alas, can't help you there (this topic seems to wander between subdomains and multiple domains). Seems your host should be able to tell you whether they use virtual hosting or symlinks or whatnot to point your other domains to the code base directory?

Good luck!

marcoBauli’s picture

NOTE: setting up multiple sites from a single codebase means sharing every thing, nodes as well.

Does any of you guys know if would this transform into penalties in Search Engines for duplicate content?

Or shouldn't we worry being every site in it's own domain or subdomain and thus being seen by google and others as completely separate sites?

comments apreciated!

benthere’s picture

Sharing all content between sites would be penalized by Google.

Most multi-site setups would only share partial content, though (such as users). Many other multi-site setups instead share no content, only the Drupal codebase and possibly modules, to allow for easier maintenance, upgrades, etc.

--
Cheap, reliable Drupal hosting: 200GB | 2TB
Save $75| DH75OFF coupon for 1 year ($3.75/mo!)
Save $50| DRUPAL50 coupon for monthly ($10/mo!)

marcoBauli’s picture

i created some subdomain multisites to try to fill some smaller niches of contents first, and not giving the earlier visitors the impression of being in a big empty room.

I also needed these niches to be separated sites so to customize the contents and navigation links (blocks) in them to actually avoid users navigate to still empty areas.

For the moment i redirected with 301 couple of www.mysite.com/section to section.mysite.com, so Google shouldn't see it as duplicate content, isn't it?. As soon as things start moving and contents coming, i will redirect back and follow your advice.

is this a good strategy in your opinion? i'm moving my first steps in SEO, so any advice is gold to me :P

cheers

NancyDru’s picture

For those few who are not aware of it, you do not need a separate FTP client on Windows (I believe starting with 2000).

I have a personal home page on my PC, so it is secure. I have an FTP link there that is ftp://username:password@ftp.mysite.com. When I click it, I get a window that looks just like any other folder view. I can just drag and drop like any other folder. I find this is so much more convenient that a separate client program.

Nancy W.
proudly running 3½ sites on Drupal so far

khalil-1’s picture

But.

I think either I'm too tired or I've misread things.

So I have my main domain. http://www.islam-zwart.net which has Drupal 5.1 installed.

My host allows me to create subdomains that behave as if they were folders within the primary doman. So for the purpose of this exercise, I created http://justatest.islam-zwart.net and I would like to share the installation of Drupal made on my main account with that site. Eventually, I'd like my main site to be a springboard for up to 6 differnet sites - a personal blog, sites I create for the classes I teach, hobby sites, perhaps a site for my partner and child.

I also have two domain names that are operated from my main domain name. This is where I demonstrate my n00bness, as I don't really understand how this works on the server side, but the folders for those domains are within my main domain folder when I FTP in to transfer files. I'd like to run Drupal to each of those domains as well and think the answer to these questions will help me with that.

I'm stuck and have the following questions:

1. Do I need to use SSH access? I've read contradicting statements above. Or I'm too tired to correctly read.

2. Do I need a different database for each subdirectory? Ideally, each subdirectoy would have it's own theme and look and I'm trying to learn how to do this with Drupal. My preference is to have my installation be as lean as possible and I'd like to do it with one install.

3. What are the edits I need to make to the settings.php page?

4. What about an index page for each subdirectory?

5. I'm starting to lose myself, but would apprecaite any help...

Thanks!