I don't know whether anyone has time to generate a process for me - and doubtless others - who need to rationalise two or more sites into one using the multi-site facilities.

A search of the avaialble literature has confused me. The entries I've found are well meaning but assume a level of knowledge that I'm sure many site builders simply do not have.

As an example, the installation instruction for multisite manager say

Put something like this on your Apache config

Somewhere else I deduce that my Apache config is the same as my .htaccess file

Elsewhere I'm told to set up sub-files in my /sites/ register but I don't know what to call them: are they /mysite/site/www.myothersite.com or what

Ideally I'd like a run through of the whole process starting from there are two sites

www.mysite.com

and www.myothersite.com

which stand on two different data bases and need to be integrated into a multisite for admin efficiency but need to remain separate from a visitors point of view.

I'd like to say here and now that I and many like me are immensely grateful to the work given free gratis and for nothing by drupal contributers - but sometimes I think I'm drowning

Comments

marquardt’s picture

It can be difficult - especially when setting up a web server, which means not only dealing with Drupal, but also with Apache and Linux and name resolving and...

I'll try to explain my understanding of multisites. It does require a bit of background on web servers, and on Apache in particular. Oh yeah, and do expect typos, especially in domain and file names. Do your own research in the multisite documentation once the fundamental ideas have become a bit clearer...

Name-based virtual hosts (Apache)

The Apache web server has a feature called virtual hosts: It can be configured so that it delivers different web sites through a single Apache installation on a single computer (with a single IP-address) based on the domain name for which a request comes in. Technically, his works by assigning a particular file system directory to each domain name being served by the web server. For example, if the (physical) web server receives a request for www.mysite.com, it will send back whatever it finds in the directory configured for that domain. If the next request is for www.myothersite.com, it will return the content from the directory which is configured for that domain. This is the basis for all shared web hosting - one Apache installation can serve the web pages of hundreds of different web sites (or users. Or customers).

This configuration is setup in the system-wide configuration files for the Apache web server. On a typical Linux server, these files are usually located in /etc/apache or /etc/apache2; the detailed setup depends on the Linux distribution. It is not possible to introduce additional virtual hosts at the level of .htaccess files, simply because the web server has already gone through the virtual host resolution when it reaches that file. So if your hosting plan does not give you the option to add more domain-name based virtual web hosts, you won't be able to get them by editing the .htaccess file.

Multisites (Drupal)

In a way, the Drupal multi-site idea is very similar - instead of having several installations of the Drupal source code (one for each domain), you just use a single installation, and direct the requests to all domains to the one Drupal installation directory. Now Drupal also checks the domain name for which each request is intended, and then applies the domain-name specific configuration (= web site).

This domain-name specific configuration contains information on the database for that site, in particular the name of the database itself as well as the user name and password for that database. In general, you will still need a separate database for each web site (there are options to share a single database, or parts of the data base, but let's skip that for the sake of simplicity).

The Drupal configuration files are stored in the sites subdirectory of your Drupal installation. Drupal finds the 'right' one for any given request by following strict naming conventions: The configuration for mysite.com will be in sites/mysite.com, and the one for myothersite.com in sites/myothersite.com. If there's a request for a domain that doesn't have a specific configuration, the one in sites/default is used.

There are different option on how to name the different domains a single Drupal installation serves. You can have entirely different domain names (but see below). Or you can use subdomains, like sub1.example.com and sub2.example.com (in these cases, the configuration directories would be in sites/sub1.example.com and sites/sub2.example.com, respectively). Or you could use something like www.example.com/site1 and www.example.com/site2 - the corresponding configuration directories would be in sites/www.example.com.site1 and www.example.com.site2 if I have understood the documentation correctly. Note that the '/' in the site names has been replaced by a '.' in the configuration directory name.

Putting things together

If you want to use entirely independent domain names (like in your example), you must tell Apache to direct requests for both domains to the same Drupal installation. That is, you must configure Apache so that two different name based virtual hosts point to the same physical directory - the one where you have installed Drupal. Thus, you'll need access to the system-wide Apache configuration (if you fully control your Apache installation, you can also get away with having all http requests being sent to the same Drupal installation, but that won't work in any shared hosting environment, of course).

If you want to use a sub-domain (as in sub1.example.com and sub2.example.com), you can make use of the way the domain name resolution in the internet is usually set up: In most cases, sub domains are resolved as the main domain name. That is, if you type sub1.example.com in your browser address field, that will bring you to whatever IP-address the main domain (example.com). Actually, the use of www.example.com is just one specific example of this domain name resolving process... Anyway - if this works, sub1.example.com and sub2.example.com will both end up at example.com, that is at your Drupal installation - which can then do its separate things for each sub-domain (if different subdomains do not resolve to the same IP-address, you need to talk to your domain name provider).

And finally, with subdirectories (as in www.example.com/site1 and www.example.com/site2), you do not even have to rely on the correct domain name resolving.

Uhh. This got very long - my apologies. I said it can be difficult, didn't I? I hope it helps a bit anyway... And I hope there are not too many mistakes in all of the above - please correct whatever I've got wrong here!

rogerwebb’s picture

Thanks for an interesting and instructional reply - much better, I might add, than anything else I have found.

Just as a bit of background - I need my sites to be accessed by a user from its own url

Two follow up questions before I make a start.

Apache Config
All my sites are with one provider - 1and1 - and they allow me to 'point' a URL into any of a multitude of directories within my account. At this stage all my sites are in different directories within my account.
Is this a 'front end' for the control of 'virtual hosts' or is this something different?
Then in my /sites/myothersite.com
Do I have to put a settings.php in each site-specific subdirectory of /sites ?
Is the file generated in the multisite manager module the complete file or do I just substitute the code generated there for the relevant portions of the settings file in /sites/default
And finally 'shortname'
Multisite Manager Settings refers in one of its input boxes to 'shortname'. Is this a shortname to use for the subdirectory ie /sites/shortname rather than /sites/myothersite.com, and if so does this 'shortname' need the .com suffix
marquardt’s picture

Thanks for the nice words;-)

I'm not familiar with the 1and1 hosting. From what you write it sounds like this is indeed their interface to setting up virtual hosts - couldn't you just have two (test) domains pointing to the same directory and place a simple index.html in there to confirm that things are working ok? Or contact their user support...

You do indeed need one settings.php for each site. In most cases, this is a copy of the file sites/default/default.settings.php, but with the $db_url modified to point to the database for that particular site. If you have individual installations working fine, I would actually think it should be sufficient to copy their settings.php into the correct sites-subdirectory of your multisite installation (no guarantee, though). Things are becoming slightly more complicated if you share some tables (like user information) between sites through the $db_prefix variable, but I would recommend to get a basic setup working first, and then continue from there. By the way, the defaults.setting.php file has a lot of documentation inside.

Unfortunately, I'm not familiar with the multisite manager module either - you could try the issue queue for that module to find out on more specific details.

Good luck!

rogerwebb’s picture

This first part is more to create a complete string to help other people following along this road I can confirm by a process of trial and error

I can confirm

  1. The 1and1 function allowing users to 'point' urls and specific files within their account does appear to be a front end for 'virtual hosting' although it doesn't say that
  2. Though none of the documentation actually tells you when you use the browser to enter www.myothersite.com for the first time you then get the drupal data base management screen so you can point the site to its underlying data. This comes up whether you have copied the code generated in multisite manager and copied it into a file called 'settings.php'. in www.mysite.com/sites/myothersite.com or not
  3. As www.myothersite.com already exists in Drupal it works, as you suggested, by simply copying the settings.php from www.myothersite.com/sites/default/settings.php just as well (or as badly) as using the code from multi-site manager, which though well intensioned seems to contribute little.

In any case doing all this results in an error message as you enter myothersite as follows

Fatal error: Call to undefined function block_list() in /homepages/36/d186685211/htdocs/rba-current/includes/theme.inc on line 1571
Can anyone help with this

marquardt’s picture

First, sorry for not having time to return to this earlier...

To begin with, I'm not quite sure if I understand your second point. In particular, what do you mean with "drupal data base management screen"? I've tried this on a local install by now as well (with Drupal 6.10)... I've checked the following scenarios, always having a virtual host pointing correctly to the Drupal installation:

  • With an empty sites/www.myothersite.com, Drupal falls back to the default installation. That makes sense to me, as it doesn't find a proper setup for the non-default site.
  • With only a defaults.settings.php file in there, the same happens (and I'd be happy with this behaviour as well, for the same reason). In particular, there's no automated way to start the installation of of a new multi-site instance that way.
  • With a settings.php pointing to a newly created, empty MySQL database, I get a white screen. That also makes sense to me, as there's no valid configuration in the database (yet).
  • In order to create an initial database setup, I pointed the browser to http://www.myothersite.com/install.php, which brings up the installation wizard (and this is the usual approach of the installation of a new multi-site instance of Drupal as far as I understand it from the documentation at d.o.).

Could you try to get a clean install working first (that is, without using the database from an older install straight away), just to make sure that virtual host and Drupal overall setup is working fine for multi-sites?

On your error message - if the multi-site setup is indeed working, I would guess that your older installation was somehow installed in a slightly different way. I would think that the error message indicates that your new Drupal installation, when using the older database, hasn't loaded all the required module files. Maybe this is because they were originally installed in different relative paths (relative to the Drupal installation directory, like contrib modules in sites/default instead of sites/all, or something like this - really, I'm just guessing here). Drupal's system table stores these relative paths; if they change, the contents of that table possibly need to be updated.

So I would try to sort out the plain multi-site functionality first so that I'm absolutely sure where the problem is...

Hope this helps;-)