Hello, all,

I've been wrestling with this one for a few days, and I feel like I must be missing something obvious.

I'm trying to install multiple sites off one codebase, and have the url's appear as if the sites are in subdirectories -- ie

  1. my.domain.com/dir1
  2. my.domain.com/dir2
  3. my.domain.com/dir3
  4. etc

In the past, I have set up multiple sites off one codebase with no problems -- these sites, however, were subdomains (my.domain.com, sub.domain.com, sub2.domain.com, etc)

On this install, I can get a site up and running for the main domain name (my.domain.com) by setting up a directory within sites named my.domain.com with the settings.php file configured correctly.

However, when I change the directory name in the sites folder to "my.domain.com.dir1" and make the necessary adjustments in the settings.php file and try to navigate to "http//my.domain.com/dir1", I receive the following error:

Warning: main(sites/default/settings.php): failed to open stream: No such file or directory in /home/dwf/public_html/comp/includes/bootstrap.inc on line 642

Warning: main(): Failed opening 'sites/default/settings.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/dwf/public_html/comp/includes/bootstrap.inc on line 642
Unsupported database type

Line 642 of bootstrap.inc is the line that calls for the settings.php file, so it appears that, somehow, the settings.php file is not being seen.

The site is hosted at site5, on a Linux server with Apache 1.3, php 4.4.0, and MySql 4.0.25.

As always, any help/suggestions are much appreciated.

Cheers,

bonobo
-------
http://www.funnymonkey.com
Tools for Teachers

Comments

bonobo’s picture

from cel4145, and this post in particular.

I wanted to create several sites in subfolders in a subdomain.

I use putty to access the command line on my server; all symbolic links are created through putty.

To paraphrase the steps outlined in the post cited above:

  • Go to cpanel and create the subdomain you want.
  • From the command line or via ftp, delete the folder that cpanel created for your subdomain; it should be in the root of your Drupal installation for this procedure to work.
  • Log in to your site using putty, and navigate to the root folder of your drupal install
  • Create a symbolic link with the same name as the folder that that cpanel previously created. From the command line in the root of your Drupal installation, use the following command:

    ln -s . < folder name>
    This symbolic link will redirect traffic coming into your subdomain back to the root install so that this incoming traffic can be picked up by the various settings.php files

  • In the root directory of your drupal install, create additional symbolic links (using the exact command described above) for your subfolders -- for example, create a symbolic link for "folder1" to create a drupal site at domain.com/folder1
  • Create your sites/ folder (copy the default one) as with any other multisite config using the full name of your subdomain. For example,
    sites/<yoursubdomain>.<yourdomain>.com
    For subfolders: sites/<yoursubdomain>.<yourdomain>.com.<folder1>
  • Configure your settings.php file that is in your new folder.
  • I hope this helps.

    Cheers,

    bonobo

    -------
    http://www.funnymonkey.com
    Tools for Teachers

sstrange’s picture

I've read the post about multisites but I'm not sure if I'm doing it right. Could you please help me?

This is what I've done so far.
1. Created a Sub domain with control panel.
A directory ..\html_public\weblog was created.
html_public is the root of my domain and drupal is installed in ..\html_public\drupal
Question: do I've to delete the ..\html_public\weblog directory?
2. Created a symbolic link weblog in the root of my drupal install directory. (ln -s . weblog)
3. Created a new site. ..sites\www.subdomain.domain.com.
4. Configure settings.php

Regards,
Stefan

bonobo’s picture

the url for your site?

For example, if you want the url to be http://weblog.yoursite.com, you will need to unpack the drupal files in the weblog directory.

Assuming you created the "weblog" directory using cPanel, you should delete the "weblog" directory. Then, create the symbolic link in your public_html directory.

(The reason it matters if you used cPanel, or Plesk, or some other gui interface, is that these interfaces automatically create the correct values within the apache httpd.conf file -- if you aren't using cPanel or Plesk, you will need to manually edit the httpd.conf file)

Then, create a directory within the sites folder named "weblog.yoursite.com", edit the settings.php file, and you're good to go.

Hope this helps,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

sstrange’s picture

Bill,

Thanks for your response. But I already installed drupal and I thought that if I wanted to have multiple sites I didnot have to install drupal more than once.

Situation:
- I've installed drupal in a directory ..\html_public\drupal
- I've created a redirectory webpage from my root directory ..\html_public to ..\html_public\drupal directory.
All users to www.mydomain.com are redirected to www.mydomain.com\drupal and get the drupal website to see.
This is working ;-)
- Now I a want a new drupal website. www.weblog.mydomain.com
- I've created a new site (folder) below the default drupal site (..\html_public\drupal\sites\www.weblog.mydomain.com)
- Configured the settings.php in ..\html_public\drupal\sites\www.weblog.mydomain.com
- Created a Sub domain with a gui control panel. (www.weblog.mydomain.com)
- Created a redirect webpage for users who are coming to www.weblog.mydomain.com to www.mydomain.com\drupal
- Created a symbolic link weblog in the root of my drupal install directory (..\html_public\drupal) with the command ln -s . weblog

Is this correct? Or am I doing something wrong?

Am I correct to assume that I don't have to install drupal in my new subdomain directory?
Am I correct to assume that I don't have to install a new drupal mysql database to get this new drupal site working?

Regards,
Stefan

bonobo’s picture

will all run off one codebase -- so, you will NOT need to upload a second copy of the Drupal codebase.

You will, however, need to install a second db for your second site.

RE the symbolic link: what you have might work for the second site. However, you might need to create the symbolic link in the root of your public_html directory -- I'm not sure how the symbolic link in your public_html/drupal directory will work with the redirect -- It should, but I don't have any experience doing it in this way -- so, if it doesn't work, this is a place I would start looking.

Also, when you created the subdomain using the gui control panel, you also probably created a folder in your public_html folder. You will want to delete this folder -- I usually do this using either my FTP client or via ssh (using putty).

Cheers,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

sstrange’s picture

Bill,

I'm getting close ;-)

I've created a symbolic link in the root directory of my public_html directory for weblog (ls -n . weblog). Renamed the ..\html_public\weblog directory to ..\html_public\weblog_old. If everything is working I will delete this folder.

All traffic to weblog.mydomain.com is no redirected via the symbolic link to the index.hml page in the root directory of my public_html directory.

This index.html is redirecting the user to mydomain.com\drupal (where drupal is installed).
But how will users to weblog.mydomain.com get the right settings.php if they are in the drupal dir?

I've created a folder ..\sites\www.weblog.mydomain.com with the new settings.php settings for weblog.mydomain.com.

Regards,
Stefan

bonobo’s picture

the different folders within sites directory, using the naming conventions as specified in the install.txt -- at the code level, I have never tracked down how it happens -- from what you describe, you should be good to go.

But, from running a few different multisite setups, I do know that it works, and up until now, that's been good enough for me :)

Cheers,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

monjohn’s picture

I realize this thread has grown cold, but in all of my searches on the forums, this is the closest to where I am.

I have followed all of the steps that sstrange did above.

1. Drupal is in my root directory
2. I have created sites/subdir.example.com/settings.php in which I have put my new database info.
3. I have created the subdirectory: subdir.example.com
4. I deleted the folder using cpanels file manager.
5. I have tried to establish a symlink with the following:

symlink('/home/user/public_html/people', '/home/user/public_html');

I am not getting any error so I assume it worked.

Nevertheless, when I direct my browser to http://subdir.example.com I am served my regular drupal site on the original database.

I don't know what else to try. By the way I am on a shared host.

bonobo’s picture

Hello --

Do you have root access? If so, use putty to access your directory, and create the symlink from the command line.

For step 3, how did you create the subdirectory? If you did it using your ftp client (or using the file manager within cPanel), then apache won't know about the subdirectory. Make sure to create the subdirectory using the "create subdomains" feature of cPanel, and then delete the folder using the ftp client. This way, the apache config settings remain intact, and the symlink routes the traffic, and Drupal does it's multisite magic :)

Hope this helps.

Cheers,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

monjohn’s picture

When I reran the code above and read the following error in the admin log:

symlink() [function.symlink]: open_basedir restriction in effect. File(/home/user/public_html/people) is not within the allowed path(s): (/home/claytonp:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/claytonp/public_html/includes/common.inc(1158) : eval()'d code on line 2.

As for the subdomains, I did use the 'create subdomain' function on cpanel.

I am having something odd happening. When I enter http://people.example.com, it gives me the main site found at example.com.

But when I type http://www.people.example.com, I get a 500 Internal Server Error.

I don't know what is relevant and what is not.

bonobo’s picture

From what you describe, the symlink is not being created, and the symlink function is not allowed.

You can ask your host's tech support to create it for you, or you can ask about getting root/shell access.

I hope this helps.

Cheers,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

monjohn’s picture

I will try to contact them. Thanks

monjohn’s picture

My host created the symlinks. So now when I type http://subdir.example.com I am redirected to example.com/index.php and I see only my main site.

I guess I did not ask them correctly.

Any advice?

bonobo’s picture

Check the following things --

1. Make sure the directory names within the sites directory are correct. Also, don't rename the default directory to www.yoursite.com -- leave it as default.

2. Make sure that the settings.php file within the subdir.yoursite.com is configured correctly -- if the settings in this file still point to the original database, then everything would be working correctly, but you would be getting the info from the database for your original site.

3. What are your dns settings? is your dns configured so that subdir.yoursite.com points to yoursite.com?

4. When you navigate to subdir.yoursite.com, what url appears in your browser?

5. As a last resort, try deleting/recreating the subdirectory through cPanel -- possibly (although this isn't likely) the apache conf settings got lost -- this, however, isn't likely, but it's something I would try in the interest of being thorough.

I hope this helps.

Cheers,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

monjohn’s picture

Bill I really appreciate your willingness to help. I really want to use the multisite feature, otherwise I would have given up a while ago.

1. My directory names are:
sites/default/settings.php
sites/subdir.example.com/settings.php

2. Settings file is set up for its own database. I also changed the default url to http://subdir.example.com

3. This may be where the problem lies. I confess I don't know about DNS settings. I know that when I registered my set the DNS settings were used to point to the host, but I don't know about DNS settings for subdomains. Although there was a note on cpanel when you add a subdomain that it depends upon dns, which can take a few hours to go into effect. So I suspect that cpanel takes care of this.

4. When I type http://subdir.example.com the url in browser reads http://example.com/index.php

5. I tried this but it didn't change anything.

venkat-rk’s picture

When I type http://subdir.example.com the url in browser reads http://example.com/index.php

This means that redirection has been set up for your sub domain. I am not sure if this is what you want- I think you were looking for an independent site at subdir.example.com? If so, removing the redirection for your subdomain through the cpanel (while leaving everything else intact) might get things working.

I haven't done multisites yet, so this is a long shot.

bonobo’s picture

Hello, monjohn,

Sorry about the slow reply -- some work details flared up before the weekend/holiday (I don't know where you are geographically, but I'm in the US, so the 4th of July shuts things down for us) --

Also, from reading your description, things should be working for you -- I'm not exactly sure where the problem lies -- If I had to guess, I'd look in one of three areas:

1. I remember seeing some forum posts about .htaccess settings interfering with multisite setups in some shared hosting situations -- this might get some leads on this possibility
2. Somewhere in trying to sort out the details, something small but critical got overlooked -- starting from scratch with your expanded knowledge of the process might get the whole thing running.
3. This isn't likely, but I throw it out for the heck of it -- clear your browser's cache, and see if that has any affect -- this, in all likelihood, won't do anything, but I've had problems that I've invested hours in troubleshooting disappear when I cleared my browser's cache.

I hope this helps, and feel free to post back with additional questions.

Cheers,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

venkat-rk’s picture

I hope this helps.

It certainly does. Thanks for taking the time to share your solutions with the rest of us. I for one have been perpetually postponing some drupal sites with this kind of setup because I couldn't figure things out, so it is great to know the exact steps.

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 alsoruns 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,

esadot’s picture

Swift Arrow’s picture

I've been having the same problem as bonobo, and hope his symlink solution will work. Anyhow, here's a compliation of needs for different types of domains to have their own drupal site off one codebase:

domain.tld needs:
configure: to point to the drupal install directory
folder: /sites/domain.tld
fresh settings.php in the folder

sub.domain.tld needs:
configure: to point to the drupal install directory
folder: /sites/sub.domain.tld
fresh settings.php in the folder

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

Configuring the domain or subdomain point to a folder can be done in many ways. Apparently if you use cpanel, you have to delete the folder that it makes for your domain, and create a symlink in it's place to point to the drupal install folder.

If you want a directory (eg 3 above) to point to it's own folder, then you have to create a symlink inside the drupal installation folder pointing to the drupal installation folder - that is, pointing to it's parent.
It's that symlink thing that I hadn't tried, will try and get back.
Link

venkat-rk’s picture

Hello Bill,

I am about to set up a site that works similarly (a subdomain pointing to a folder). But, do you think this can be done in a simpler way just by using cpanel to redirect a subdomain, say http://dir1.example.com/ to www.example.com/dir1?

I suspect the part that will be hard in this set up is figuring out how the redirect will work with the drupal document root.

bonobo’s picture

Hello, Ramdak,

All the above comments in this thread notwithstanding :) the multisite functionality generally works pretty well. Using cPanel should allow you to get your sites live pretty quickly and easily.

Cheers,

Bill

-------
http://www.funnymonkey.com
Tools for Teachers

venkat-rk’s picture

Thanks, Bill.

Your post has got me going a fair way with multi-site installs:-)

mlncn’s picture

I have read more documentation than should be digested by a paper shredder. All I know for sure is that everything I have tried has not worked, and this is the most active, most helpful thread in the universe.

Please, if I can do it without symlinks (or hard links, which I also do not seem able to create), and only through cpanel, try to explain it in one-syllable words maybe?

And if I do need something that probably only my host can do, can you help me describe exactly what they have to do? They're great, http://drak.net is, but apparently I'm their most demanding customer.

So: what exactly do they have to do? I have my main install in http://example.org/main/ and I would like http://example.org/mpg to use the same code base.

Thank you so much,

~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, http://agaricdesign.com/

benjamin, Agaric

venkat-rk’s picture

Short answer
I don't know if a drupal install in a subdirectory (www.example.org/mpg) can be made to resolve to another drupal install that is also in a subdirectory (www.example.org/main). I am assuming here that your main site is just a folder and not a redirect from a subdomain.

Assuming it is possible, just tell your host that you want all requests to www.example.org/mpg to resolve to the domain www.example.org/main - in other words, www.example.org/mpg should resolve to the document root or source directory of your drupal install (your codebase) at www.example.org/main.

Long answer

Meanwhile, I hope you have figured these things out:

  • Is www.example.org/mpg a folder (subdirectory) under your main domain or is it a redirect from http://mpg.example.org to www.example.org/mpg? You are probably dealing with an additional layer of complexity if it is a redirect and you also want to use the same codebase.
  • Will www.example.org/mpg use the same database (using prefixed tables) as www.example.org/main or will it have an independent db?
  • Will it share any prefixed tables or (if running independent dbs) will you share tables across the two databases for the respective sites?
  • Will it have the same modules and themes as www.example.org/main or will it have custom modules?

    Once you have decided all this, and have set up the separate subdirectory with its settings.php under www.example.org/main/sites for your mpg site, the key is to make any request to the domain www.example.org/mpg to resolve to the same document root or source directory- in your case, www.example.org/main

    According to Robert Douglass' book, here is the entry you need to make in your Apache server's httpd.conf file to make this possible:

    #Substitute your IP address
    NameVirtualHost 111.22.33.444
    
    <VirtualHost 111.22.33.444>
      DocumentRoot /absolute/path/to/drupal
      ServerName yoursite.com
    </VirtualHost>
    
    <VirtualHost 111.22.33.444>
    #note that the DocumentRoot is exactly the same for both VirtualHosts
      DocumentRoot /absolute/path/to/drupal
      ServerName secondsite.com
    </VirtualHost>
    

    Hope this helps.

mlncn’s picture

Thanks very much, Ramdak.

I've had my prefixed databases set up for days, and my settings in (several more or less) appropriately named folders.

Without symlinks and no word back from Drak.net on access to httpd.conf, I simply had no way to "resolve" (what is the word, I know it's not redirect) my new Drupal site to the main install. Except...

Domain parking -- I parked anotherexample.org onto example.com, renamed my second site's settings folder to anotherexample.org.main (unfortunately I have Drupal in a directory called main and not root right now), and if I point my browser to anotherexample.org/main I get my second site, beautifully. Never did do whatever I'm supposed to do in .htaccess, but whatever, it works.

More clarification of this issue for when I get my host on the phone is very welcome!

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

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

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

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

benjamin, Agaric

dtandukar’s picture

multisite worked well for me... but the subdomains do not remeber the password, each time i have to click on forgot password and login from that page only... what could be the problem?

DT

4cornersusa.com’s picture

It seems two seperate questions are being asked here. Causing some confusion.

The first has to do with actual multisite configuration for seperate websites using tier2 domains(also known as subdomains) In this case you can find good info http://drupal.org/node/53705 and http://drupal.org/node/43816

The other question I am seeing asked is how to access (mydomain.tld/content) using SubDomain format (content.mydomain.tld). Keep in mind that the solution for this requires thinking the same way as Drupal thinks concerning content. It is dynamic pulled from database and served. So whatever the URL is, it is processed by index.php. As such, for this you do NOT need multisite setup or symlinks. Rather it is configurable within Drupal.

Try adapting the concept used for the MySite: custom user homepages. http://drupal.org/node/119574

Keep in mind That this may require setting up Taxonomy &/or PathAuto, which you should already be using, as well as turning off subdomains in Apache.

rockefeller’s picture

Hi!

I want to implement Clean Urls function to work to the following case:

I have a main website called www.hiwz.org, the domain name is hosted in the server www.chistescool.com/hiwz

This means that when you enter hiwz.org you are really seeing chistescool.com/hiwz contents. The thing is that I have installed drupal in that subdirectory and Im able to enable Clean Url correctly at www.chistescool.com/hiwz. The problem is that when I enter www.hiwz.org and try to login to the drupal application, I have a 500 server error (when clean urls is enabled). Ive read different posts about making Clean Url work in a multisite, but most of them are in the same server (different drupal installs in main directory and subdirectory) or at least none of them has spoke about this type of issue.

I host my websites in godaddy, which allows to host other domain names in your same server. It is shared hosting and obviously mod-rewrite, etc are working because clean url can be enabled and works properly if you enter to the domain www.chistescool.com/hiwz

I want to make it work for www.hiwz.org , is it possible??

Thanks in advance for your help

WorldFallz’s picture

Yes its possible, but it has nothing to do with drupal or clean urls. You need to use your web host's control panel tools to point the addon domain (hiwz) to www.shistescool.com/hiwz.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

rockefeller’s picture

World Fallz, thanks for your advice. I think I might have been confusing with my explanation. The addon domain I had it already. I had a 500 Internal server error when I login through the addon domain or clicked in any other sections when clean url was active. As the addon domain points to a another domain with a subdirectory, What I needed to do was the following:

In the .htaccess file I had to change the following:

BEFORE
--------------------------------------------
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

AFTER (included full URL and it worked correctly from the main domain... it cannot be accesed through the other subdirectory though, still I did not needed that)
--------------------------------------------

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ http://www.example.com/index.php?q=$1 [L,QSA]

Hope it helps to others trying to do the same. Remember if you have a 500 internal server errors and addon domains involved, try this.

Good luck!

sjcctan’s picture

I have been trying to create multiple sites with one code base of drupal but failed for the past one week. After reading this post only I managed to create one in a subdomain.

However there is one thing I would like to know is the issue concerning the symbolic link which is created with the ssh command, what would happen to this link if the server is restarted? Do we need to execute the ln command again? If yes, what is a permanent solution to this if everytime the server is restarted?

Thank you.

davidhernandez’s picture

Symbolic links are like files on the files system. They are as permanent as files, so nothing needs to be done when the server restarts.

sjcctan’s picture

Hi, davidhernandez,

Thank you for responding.

What you are saying is when we execute the ssh ln command, the server will create a file and save in the system. May I know where will be this file be stored?

Thank you.

davidhernandez’s picture

No, ssh and ln are too different commands. ssh connects you to the server, ln is a command to create links. "ln -s" creates symbolic links. The link will be wherever you tell it to be. I'm assuming you'll be putting it in the root of the drupal install folder to make a sub-site work. Thus, example.com/site1 will need a symbolic link in the root of the drupal install called "site1" and it will need to link to the root of the drupal install. If you ssh to the server, and your current location is the drupal install root, the following should work: "ln -s ./ site1"

Also, you should look up the details for each command before you run them, so you understand what they are doing.

sjcctan’s picture

Thank you for your explaination. I have a better idea of what I am doing instead of following the instructions blindly.

Many thanks again.