i have a single drupal site running on a win2003 server with xampp. it's the first time i've tried drupal and i'm loving it. i dumped the drupal folder under xampp's htdocs directory so i can browse to it via the url 127.0.0.1/drupal

i need to have several drupal sites, each under a separate subdirectory (as opposed to subdomains)- 127.0.0.1/drupal/site1, 127.0.0.1/drupal/site2 etc.

i am running this on my personal computer now for testing purposes and i don't have a domain name or even a fixed IP address yet. if all works out, we plan to use drupal for all the student clubs and organization websites for our university- single drupal installations with multiple mysql databases.

how do I go about achieving this? the install instruction does talk a little about setting up multiple sites in multiple directories but I can't quite understand how to implement it in my case. i've created a folder called "new" alongside the "default" folder under "sites" with a different settings.php file that references to a different database but browsing to 127.0.0.1/drupal/new obviously didn't work. it takes me to the 404 page i specified for the default drupal site.

any help would be greatly appreciated.

Comments

narres’s picture

http://drupal.org/node/66657

I think that is that you are asking for.

Keep the sunny side up

Thomas Narres
Keep the sunny side up

sean2000’s picture

@narres:
One of the comment in the page you pointed to makes it very clear.

As you are able to use one core drupal installation with several settings.php:
* For example, for a fictitious site installed at
* http://www.drupal.org/mysite/test/, the 'settings.php'
* is searched in the following directories:
*
* 1. sites/www.drupal.org.mysite.test
* 2. sites/drupal.org.mysite.test
* 3. sites/org.mysite.test
*
* 4. sites/www.drupal.org.mysite
* 5. sites/drupal.org.mysite
* 6. sites/org.mysite
*
* 7. sites/www.drupal.org
* 8. sites/drupal.org
* 9. sites/org
*
* 10. sites/default

However, I cannot set it up as shown in the example above because I don't have a domain registered or even a fixed IP. I tried naming the folder to all of the following but these don't seem to work either:

sites/new
sites/127.0.0.1.drupal.new
sites/146.57.180.54.drupal.new #<-that's my machine's IP right now.
sean2000’s picture

i should mention that i have clean urls turned on and working. i am not an expert on apache.. but i am thinking i need to tell apache/drupal to make an expection when the /drupal/new url is requested- to not look for this url within the default drupal site (that's why it's returning the 404 page i specified in the default installation). maybe some fancy rewrite/alias rules is what's needed. just speculating.. any ideas?

thanks
sean

narres’s picture

Did you try with domain localhost.

I cannot try, cause I have only public and no local servers ;)

Thomas Narres
Keep the sunny side up

sean2000’s picture

tried that.. but still the same problem- a 404 page from drupal.

Quint’s picture

you could probably put it in the HOST so you could use any domain name you wanted (for testing) and instead of looking it up in the global DNS it would find it in your local HOST file and send it to your Apache. Just a thought, I think that should work.

for example

fredsmith.com 192.168.1.66

1.66 would be your apache server

Quint

cmsproducer’s picture

If each of the installations in the subdirectories are independent of each other, then you do not need to cater for others in any one sites folder.

- Create the various sub-folders
- Load Drupal files into each of the subfolders (each set of files will have it's own .../sites/default/settings.php)
- In each settings.php file, point to the relevant database for each installation and make sure that you have the complete $baseurl that includes the subfolder fot he installation at hand
* You should be able to access each installation now by calling it's URL (including the folder-name)

Let me know what you get and I can troubleshoot some more.

-----
iDonny - Web Productions: Web Strategy, CMS Design, Branding, & Production

sean2000’s picture

@iDonny:
i don't think I want to run several instances of drupal because for the project i am working on we'll have to have about 20-25 different drupal sites and there are more to be added in the future occasionally. if i understand correctly, updating/upgrading things, and general site management like adding modules etc would be much easier on a single instance instead of 25+ sites.

jsloan’s picture

I use the exact setup as yours for our Intranet development. I currently host 5 dev sites, 10 training sites and 25+ departmental sites on one installation of Drupal-4.7.2.

We use the same DNS name for the site (webdev.mchs.com) and all of the sites are directories under a virtual directory named "drupal" so the urls are:
webdev.mchs.com/dev0
webdev.mchs.com/dev1
webdev.mchs.com/dev2
etc. etc. etc.

Apache Setup:
I placed the Drupal directory at "D:/drupaldev/drupal-4.7.2/" so I added this at the bottom of my apache conf file. d:/xampp/apache/conf/http.conf

# add some Drupal sites
Include conf/drupaldev.conf

then I added a file named drupaldev.conf to the /apache/conf directory

# filename: drupaldev.conf
# Development - Drupal sites
#  - please add sites in alphabetic order
#  - use lowercase only
# ----------------------------------------------
Alias /dev0 "D:/drupaldev/drupal-4.7.2/"
Alias /dev1 "D:/drupaldev/drupal-4.7.2/"
Alias /dev2 "D:/drupaldev/drupal-4.7.2/"
Alias /dev3 "D:/drupaldev/drupal-4.7.2/"
Alias /dev4 "D:/drupaldev/drupal-4.7.2/"
Alias /dev5 "D:/drupaldev/drupal-4.7.2/"

<Directory "D:/drupaldev/drupal-4.7.2">
    AllowOverride All
    Options +Indexes
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
</Directory>

...now all of the alias names point to the same location - this is where Drupal takes over.

Under the /sites directory I made 5 copies of the /default dir naming each as follows:
webdev.mchs.com.dev0
webdev.mchs.com.dev1
webdev.mchs.com.dev2
webdev.mchs.com.dev3
webdev.mchs.com.dev4
webdev.mchs.com.dev5

... or in your case
127.0.0.1.site1
127.0.0.1.site1
etc.

Edit the settings.php file in each directory to point to the correct database and you are set to go.

jsloan’s picture

To get clean URL's with multi-site I added the following to the .htaccess file

# rewrite commands for drupal dev sites

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/dev0/.*
  RewriteRule ^(.*)$ /dev0/index.php?q=$1 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/dev1/.*
  RewriteRule ^(.*)$ /dev1/index.php?q=$1 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/dev2/.*
  RewriteRule ^(.*)$ /dev2/index.php?q=$1 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/dev3/.*
  RewriteRule ^(.*)$ /dev3/index.php?q=$1 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/dev4/.*
  RewriteRule ^(.*)$ /dev4/index.php?q=$1 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/dev5/.*
  RewriteRule ^(.*)$ /dev5/index.php?q=$1 [L,QSA]

I'm not an mod_rewrite expert so any improvements to this scheme would be appreciated!

sean2000’s picture

thanks!
i got multiple sites running as per your instructions.

clean urls are not working on the subsites though.

i am no good with rewrite rules either.. maybe you could help.

this is what my xampp/htdocs/drupal/sites directory looks like:

default
my.ip.add.ress.drupal.new
my.ip.add.ress.drupal.site2

(edit: i found that using 127.0.0.1.drupal.new or localhost.drupal.new etc for these folder names doesn't work)

so this gives me
http://my.ip.add.ress/drupal/
http://my.ip.add.ress/drupal/new
http://my.ip.add.ress/drupal/site2
all running on different DBs, which is working swimmingly.

i added this to the .htaccess file under the drupal directory (just below the rewrite rules that were already in there):

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/new/.*
  RewriteRule ^(.*)$ /new/index.php?q=$1 [L,QSA]

when i "run the clean url test" from subsite "new" (eg. http://my.ip.add.ress/drupal/new/admin/settings) it pulls up the admin/settings page for the default site (or an access denied/403 error if i am not logged in to the default site).

i did NOT add a similar rewrite code block for "site2" to the .haccess file. still, http://my.ip.add.ress/drupal/site2/admin/settings leads to the same default admin/settings page. so it appears that the block of code isn't really doing anything.

any idea what i am doing wrong?

thanks again. got a major problem out of the way. clean urls would be really sweet though.

jsloan’s picture

... since you are under the first directory of drupal try appending that to your rewrite conditions.

RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/drupal/new/.*
  RewriteRule ^(.*)$ /drupal/new/index.php?q=$1 [L,QSA]

and remove or comment out the rewrite rules that were already in there.

I'll try to test this later.

sean2000’s picture

i think i tried that.. but i didn't comment out the other rewrite rules that came with the default installation. i'll try it again on monday morning. i'm done for the week and i have a strict "no work at home" policy. :)

thanks again.

jsloan’s picture

... be sure to comment out the rewrite rules that came with the default installation or make sure that your new rules come before.

sean2000’s picture

that's what it was. i commented out the previous rules and it seems to be working now.

thanks to jsloan and everybody else for all your help.

dman’s picture

I know it's an old post, but I'd like to say that this solution (after hours of looking through other threads) finally worked for me.
I too wanted my subsites in subdirectories, not subdomains (It's easier to make them come and go during development, and to switch to an overview)

I wanted to use Apache Alias, not symlinks, which are conceptually confusing to use for an entire website content - especially when doing backups. Plus, it was stored on a FAT32 disk :-)

I discovered that Apache Location chunks couldn't help, as they ran AFTER .htaccess files had already done the rewrite.
I couldn't use Directory blocks, as there was no file directory, just an Alias.
I also found that it was hard to scope the RewriteBase. Placing it between RewriteCond and its RewriteRule didn't work.

I was getting success pretty early with Alias - but not with clean URLs - which were returning content from the core site when I requested the page from a subsite.

jsloan's work-around, making the normal rewrite first check if it's in the core directory (the one with the Drupal files in it) and other rewrites do almost the same thing, solved my problem.

The hidden trick is that the Dondition works with the absolute URI, but the Rule immediately follows it is working on the truncated - or relative remaining filepath after the current working directory was trimmed off it. 'Twas confusing for a bit.

my webserver files

/var/www/stuff
        /drupal_5 - drupal installed here
        /other_stuff

my http:

http://monster/ - other webstuff
              /drupal_5  - core site
              /resourcedb - virtual drupal site. NO FILES really exist for it.

resourcedb is called into existance using apache Alias, and Drupal multisite settings.php

resourcedb is redirected to using jsloans modification to my drupal_5/.htaccess.

  # Special case support for the other subsites that use this same codebase
  # whilst being served from a subdirectory of the main site.
  # Similar rules as below, but unique sites need to remember they are unique.
  #
  # This is corresponding with the drupal multisite config file :
  #
  #  sites\monster.resourcedb\settings.php
  #
  # and my apache conf:
  #
  #  Alias /resourcedb /var/www/drupal_5
  #
  # The normal rule below has been amended to only rewrite its own requests
  # ( by checking it's really in drupal_5 ) or double rewrites would happen and pain...
  #
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/resourcedb/(.*)$
  RewriteRule ^(.*)$ /resourcedb/index.php?q=$1 [L,QSA]

I'd like to have found a way to put this directive in the Apache conf instead, but this works and will do.

There are no files and no filesystem tricks for this virtual site, just some conf file things. I'm yet to see where it stores its /files :)

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

twohills’s picture

You saved my butt with this entry, so giving back:

my subdomains are of the form www.example.com/orN where N is any integer

In .htaccess, BEFORE the standard rewrite rules, insert:

  RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/(or\d+).*
  RewriteRule ^(.*)$ /%1/index.php?q=$1 [L,QSA]

The (or\d+) means "or" followed by any digits so you need to change it to whatever format you plan on using. Your example of dev0, dev1... becomes (dev\d+) or (dev\d) if there will only ever be 9 or less.
It gets substituted for %1 in the next line.
So unlike your rewrite code, only need to write this once.

then in httpd.conf, same as your solution, one of these for every subdomain, so at least only one file needs updating for a new one:

Alias /or1 "C:/Apache2/htdocs/master"
<VirtualHost *:80>
    DocumentRoot "C:/Apache2/htdocs/master"
    ServerName www.example.com/or1
</VirtualHost>

I tried to get "AliasMatch /or\d+$" to work instead of Alias, to make it generic, but got server errors. Nothng useful in the error log, Drove me nuts.

Finally create a sites/www.example.com.or1 directory with /modules, /files, and /themes subdirs as required.
Copy in settings.php and set $base_url in settings.php to www.example.com/or1, or you can set it to

$base_url = 'http://www.example.com/'.trim($_SERVER['REQUEST_URI'],'/ ');

just for one less bit of code to change with each new subdir

I'm workign on a way to have only one settings.php - there is a "universal" one on the web soemwhere

Hope this helps someone.

I have to say, multisite is UGLY.

Thanks again

magnusprime’s picture

I have not done this one windows, so I dont know for sure if it will work, but the way I haveit set up on linux is as follows.

I create a sub-domain on my host (sd1.domain.com) and then in my web root, i create a symlink for sd1 to point to the web root. Then I create the folder sd1.domain.com in the sites directory, and create its own settings.php file.

Work just fine.

ben928’s picture

Love the support here!

votersmind’s picture

http://drupal.org/node/148455

Here is a link to a problem that I am having. I have 1 primary domain and two alternate domains listed in the primary domain. Both new domains work, but when I tried to install the new Drupal 5.x in both with seperate databases for each new install in the new domain directories, the first one worked and connected to the first new database created for it and the second one did not. Any thoughts on why this is?

volunteermama’s picture

I'm adding a second site (subdomain) with same database using a database prefix...
when I go to my subdomain I get warnings that my tables are not there... like drupal does not realize this is the first access to a new site and does not give me the initial config webpage.... any thoughts?

Quint’s picture

Did you add the site to the /sites/ directory and edit the Settings.php file?

Quint
Shalla.Net

volunteermama’s picture

I had to add install.php to the end of the url....

dewolfe001’s picture

I have set-up a site in the sites directory. I experimented with MANY combinations of .htaccess and httpd.conf changes.
I have groups.comminit.com -- this is a sub-domain. I have sites/groups.comminit.com and that appears to work fine. I tried to get groups.comminit.com/specialgroup into play. I did up a sites/groups.comminit.com.specialgroup directory. I experimented with exposing and hiding the $base_url in the settings.php -- that made no difference.

Our rewrite code in .htaccess looked like this by default

RewriteCond %{REQUEST_FILENAME} !server-status
RewriteCond %{REQUEST_FILENAME} !phpinfo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

I am running this in Apache 2 on an Ubuntu LTS server. Has anyone had success with the same set-up when they tried to set-up a sub-directory? If so: what did you do? Do I have to make a new conf file for sites-enabled/sites-available ? Do I have to add an Alias in the groups conf file? What am I missing?

All the best,

Mike

ronsnow’s picture

I have a similar problem in that i have drupal 6.14 in a subdirectory.
I want to run the domain www.example.com along with the subdirectires of
www.example.com/subdir1
www.example.com/subdir2 etc

I got the rewrite code to work for the primary www.example.com so that even though its going to the drupal install directory, the URL shown to the user is still www.example.com. However, if I try to access any of the subdirectories for the site, for instance www.example.com/subdir1 I only get the default (www.example.com)

I have all the drupal install directories properly set, that is in the sites directory I have:
all
default
example.com.subdir1 etc

and the sites each have a valid settings.php file and the modules and themes are in 'all' subdirectory.

I don't have access to apache so only have .htacess to work with and symlinks on my host service yield a security 'access denied' error.

So does anyone - anyone at all- have a solution that might work for me.... the rest of us...?