We're trying to create multiple websites as community forums, with registered users contributing content. So Drupal seemed like an obvious choice.

...but after hours upon hours of fiddling around, reading forums, reading handbooks, etc... I can't help but feel that I'm missing some really central concept. So, please respond with links and/or personal "Eureka!" moments.

What we've done: We have all the domain names registered and static html pages up. J has successfully implemented Gallery2 on one of the domains. Then we learned about Drupal and decided to implement it for all of the sites.

(Note that we want the different domains to have different content (including different photo galleries using Gallery2 on the different domains). However, since there will be some overlap of members for the different sites, we'd like to use Drupal to allow users to easily switch between sites, and ideally, have different priveleges on the different sites (ie, a full member on site1 and a friend on site2, where a full member can post/edit content, but a friend can only view). Trust me...the ideas have been fully hatched and getting this implemented would be awesome...and I know it can be done!)

So, we're doing everything on a test site on our hardrive (running Windows) to learn Drupal using the set-up that J got going when he was learning Gallery2. Apache - check. PHP - check. MySQL - check. The web-root is My Documents/Websites/www. Drupal is in a drupal directory (My Documents/Websites/www/drupal). I used Junction to get symbolic links for the domains (My Documents/Websites/www/site1) to point to the drupal directory. I have a folder for site1 in web-root/drupal/sites/. I have a settings.php file in there and the modules and themes folders. I got the gallery module to work, so our gallery (in web-root/oldsites/default/gallery2) can be accessed through localhost/drupal/gallery.

I created a database "drupal" in MySQL and got Drupal running. But, localhost/drupal looks the same as localhost/site1 looks the same as localhost/site2... "Maybe I need different databases?" I thought. So I created "drupalsite1" database in MySQL, changed the database name in the settings.php file for site1 and go to localhost/drupal/site1/install.php. Now, I have a new localhost/site1, but localhost/drupal and localhost/site2 look just like it, too. By looks the same, I mean that it doesn't seem like there is any difference in terms of admistration and content between the sites. A user for site1 is a user for site2. The gallery blocks are visible to all sites. The headers and titles are all the same. "Home" goes to localhost/drupal, not a different front-page for each domain. etc...

J and I have done a fair amount of programming (we're not programmers, but we are the people our coworkers go to when they want a program written) so we're not afraid to delve deeper. But PHP and MySQL are really new territory for us...we're used to Basic, C, and Perl with a smidgen of HTML. *However*from reading all of the "What Drupal can do for you" documents on drupal.org, I really did not think you needed to be a programmer to get something like this going. So what are we missing?

-K

Comments

dman’s picture

Sounds like you've done most things as expected.
A search on multisite throws up some useful articles that may help you.

You can have different databases, yes, so that should have worked. Although if you are planning to share users you may investigate setting prefixes as described in settings.php and this page. You can have a common 'users' table and unique 'user_roles' so I think that'll work.

However, if you are accessing the same data from your two setups, your second database doesn't seem to be getting used.
Double-check your settings.php, and especially the name used for your sites/site1 directory. The search patterns used there are not exactly what I assumed they'd be, so I found this was happening to me and my subsite was actually using sites/default instead.

A little matching up between my local hostnames and subdirname was needed to get the right sites/foldername.
Throw some debug into the settings.php file (even just bad syntax to trigger an error) to ensure the right one is being read. I set the site_name variable explicitly as described at the end of the file just to be sure what I was looking at.

 * 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

... note that this pattern does NOT support
sites/test
but instead requires
sites/localhost.test
instead. (!) Was that it?

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

k_and_j’s picture

Thanks davidjmcq and dman. I haven't actually been working on this very much in the last few weeks until today, so I haven't had to spend that much time to resolve this problem :)

Changing the directory from sites/site2.com to sites/localhost.site2 worked *but* I can't use sites/localhost.site2.com or sites/localhost.drupal.site2.

I think I understand why, but I just want to put this out there for other users. If anyone sees any problems here, please let me and the rest of the Drupal community know.

Using the same web-root as in my first post (My Documents/Websites/www/), drupal is installed in web-root/drupal. I know that my shared-hosting server creates folders for each add-on domain in web-root without the ".com" so that "http://site1.com" has a folder in web-root called "site1" and the same goes for "http://site2.com", etc... For this reason, my symlinks (if you're using Windows, you'll need a program called Junction http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx to create symlinks) point from web-root/site2, *not* web-root/site2.com, to web-root/drupal.

The name of the symlink directory (in web-root) determines whether sites/localhost.site2.com or sites/localhost.site2 is the correct drupal folder name. So this I get.

Now, why did I try to use localhost.drupal.site2? This is because site1 is my default site and I have apache configured to point to web-root/drupal, so that site1.com's URL actually shows up as http://localhost/drupal/. Therefore, when I created a link from site1 to site2 in my drupal content using href="site2.com/index.html", the hyperlink's URL was http://localhost/drupal/site2.com/index.html.

I am now using href="../../site2.com/index.html", which works on my local machine (ie, it goes to http://localhost/site2.com/index.html, which uses it's own drupal database), but I'm not sure if this is actual good HTML practice. No big deal, because I can just change the ../../ to http:// when I go live if need be.

Meanwhile, the whole http://localhost/drupal/site1.com URL was bothering me. I know that site1 is my default, but I don't want the URL when it goes live to be http://drupal/site1.com and it doesn't look like anyone else who uses Drupal has this type of URL. I was hoping it would just go away when I went live, but I thought I'd try to get it to look right on my local machine anyway. This is actually really easy. I just made symlink for www/site1.com -> www/drupal . Now my URL is http://localhost/site1.com/ . Note that if you've already put site1.com up without the symlink, you can do the following to make sure that you can go backwards if you change your mind:
Assuming your database for localhost/drupal/site1.com is called "drupaldb"
Create a new database called drupalsite1
Create a directory web-root/drupal/sites/localhost.site1.com
Make your symlink from web-root/site1.com -> web-root/drupal
Change the $db_url in the settings.php in this folder to drupalsite1
Go to http://localhost/site1.com/install.php
You'll have to re-do all of your site setup again but you can always go to localhost/drupal/site1.com if you decide this was a bad idea or if you want to see what your previous set-up was.

I haven't really done anything else besides make sure the content on the two sites is different and the URL's look right, so I can't speak to whether this set-up is going to accomplish my aforementioned goals...

-K

venkat-rk’s picture

I have no idea really, but it *sounds* like the multidomain module might be of some help.

----
Previously user Ramdak.

davidjmcq’s picture

I'm running two sites.. one for testing, one live and both on the same host/drupal/mysql/apache

You need to be looking at the sites directory in your drupal filesystem, and you need to use a prefix for mysql to differentiate between the two databases.

In drupal/sites/ you will see a default set up.

Here are my rough notes from when I did it... might be hard to follow though!

# multi sites, multi domains #

multiple directories needed in drupal/sites/
eg: drupal/sites/foo.com
copy the original settings.php into each directory, so you finish up with drupal/sites/foo.com/settings.php
make drupal the root directory for the relevant sites-enabled file in apache
When logging in for the first time, there must be a directory matching
the fqdn of the domain, with an original settings.php
make sure that you use the advanced/prefix option when first logging in
for this write up, database=drupal, user=drupal, passwd=xxxxx
prefix for foo.com is foo
prefix for bah.com is bah

Hope that helps