Hi,
I've been trying for the past week to create a multisite on a LAMP with no luck. My objective is to add new sites to my existing Drupal code base that have their own database.
My multisite set up is as follows:
Drupal is installed in /var/www/html/. This directory contains the core directories (e.g. files. modules, includes, and sites).
In "sites", there are the directories "all", "default", and "mysite.com", which is the new site I'm adding.
In "mysite.com", there are the directories "files", "modules", "themes", and "tmp". In addition, there is a symlink "html" that points to /var/www/html/. To be more specific, CDing symlink takes you to /var/www/html/sites/mysite.com.com/html which contains everything that /var/www/html/ contains.
In settings.php, I have set $base_url = 'http://localhost/html'. However, browsing to http://localhost/mysite.com brings me to a "Not Found" page. But, browsing to http://localhost/html/sites/mysite.com/ brings me to a directory page which contains all the folders in /var/www/html/sites/mysite.com/. Regardless, I'm unable to view the added Drupal site.
Hopefully, someone will be able to point out my mistake or something that I am missing in my set up.
Many thanks,
Thai
Comments
Your symlink is in the wrong place
Your html symlink should be in your web root directory not in a sites subdirectory. The point of that is that http://localhost/html is served up by Drupals index.php file the same way http://localhost is. This doesn't require a symlink, an aliased path in your webserver config could also achieve the same effect - you just need some way for that url to map to Drupals index.php file.
The html directory (which isn't a symlink) in /sites should then just contain the same files any other sites directory does (eg settings.php etc).
The directories under sites are for site configurations, not the code that serves the site. Once your webserver is configured so that the url for your site gets served by the main Drupal index.php file, Drupal will then look for the appropriate configuration in your sites directory.
All multisite is (at its most basic) is a way for Drupal to choose which settings.php to use based on the incoming url. It is up to your webserver config to make those urls still get served by Drupal.
--
Cheers
Anton
--
Cheers
Anton
webserver config
Thanks for the explanation. From what I understood, I need to either
A) Change the symlink so that it's in /var/www/html/ (the web root directory where Drupal is installed) and have it point to the directory /var/www/html/sites/mysite.com.com/ (which contains the files of my new site).
OR
B)Create an aliased path in my Apache 2 webserver config so that when Apache receives a URL it checks one of my hosted sites.
I'll look into doing B, thanks!
Pretty much
Setting up multisite is a process with two separate stages. Keeping them separate will help you diagnose which stage you are having problems with.
Stage 1 is configuring your infrastructure (ie your webserver or its filesystem and/or your DNS) so that the urls (these could be domain name based or subdirectories) you want for your sites get served up by the main Drupal top level directory (ie index.php).
You can test this by trying all the urls in your browser - if your original Drupal site (ie the one in the /sites/default directory) doesn't load and work properly, you haven't configured your infrastructure properly yet and don't bother with stage 2 until this test works.
After all Drupal can't service the request unless the request comes through Drupal itself (ie the index.php file) - if the server sends the request somewhere else, Drupal won't even know about it. That sounds like a great big "well duh!", but many people fail to grasp that and blame the easy Drupal bit (stage 2) for being difficult or not working.
Stage 2 is configuring Drupal by putting subdirectories for your sites in /sites. This stage is really simple but requires the first stage to be working properly first.
Note: your original Drupal site out of the box is actually a multisite instance anyway - it just happens to be the default fallback site that is used if it doesn't find a better match in your sites directory.
--
Cheers
Anton
--
Cheers
Anton
Reading your post again
A was totally wrong, and B was unclear as to what you meant by "hosted sites".
But my reply is still accurate.
--
Cheers
Anton
--
Cheers
Anton
symlinking and setting the web config
So, I believe I'm not having any problems with "Stage 1" since my first (i.e. Drupal) site works fine. Styro, I followed your suggestions and tried two things:
First, I created a new symlink that is located in the root directory (i.e. /var/www/html/) and points to the settings.php file belonging to the site I'm trying to add (mysite.com). I also tried pointing the symlink to the mysite.com directory (/var/www/html/sites/mysite.com). Neither one of these got the site to work.
Secondly, like you advised, I reconfigured my Apache2 webserver by adding the directive "ServerName http://localhost/html/mysite.com" to the file "default" in /etc/apache2/sites-available/. I also tried creating an aliased path using the derivative "ServerAlias http://localhost/html/mysite.com". Unfortunately, neither one resolved the problem.
I'm sooo going to write up a How To for setting up a multisite on a LAMP once I get this to work.
Below is the configuration for "default" in case this might help diagnose the problem.
NameVirtualHost *
ServerAdmin webmaster@localhost
#Added by Thai
#ServerName http://localhost/html/thefreeu.com/
ServerAlias http://localhost/html/thefreeu.com/
DocumentRoot /var/www/
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
Still not quite sure what you want to achieve
First you need to spell out what the urls for each of your sites are supposed to be.
Not quite. The test for stage 1 isn't that your original site still works - it's that every url for all your multisites gets you to your original working site. It still sounds like stage 1 hasn't been set up properly.
So you have a settings.php (linked from /sites/mysite.com/settings.php) sitting in your root directory? Drupal doesn't look for settings.php files in it's root directory, so that won't do anything.
Again why?
The only symlinks involved should be in your Drupal root directory and point back up to your Drupal root directory.
eg if you main site is http://localhost and you want another site at http://localhost/subsite, you create a link called subsite in the root directory (this is what Apache will follow for http://localhost/subsite) and that link points at '..' (ie it's parent directory which is the Drupal root directory). That way a request for http://localsite/subsite/index.php really gets served by http://localhost/index.php - which is your main Drupal site.
That is the stage 1 testing I talked about - when your subsite gives you your original site, stage 1 is working properly.
ServerName and ServerAlias are for hostnames (eg for the top level server setup or in virtual hosts) not urls and have nothing to do with subdirectories. The ServerAlias directive completely separate from the Alias directive.
Note: during stage 1 nothing in your web server configuration will have anything to do with anything under your sites directory - the sites directory is only involved in stage 2 which is purely Drupal - no symlinks or Apache directives in sight. The stuff in /sites is internal to Drupal - nothing to do with web servers.
Also note: (stage 2 only) if you create a directory /sites/mysite.com that isn't going to match something like http://localhost/mysite.com it is for matching http://mysite.com - you should leave dots out of subdirectory based site names or Drupal will think they are hostnames.
But I'll reiterate - you won't be able to get more specific help until you spell out exactly what sites you want and what their urls (are they subdirectories or hostnames etc) will be. It would probably also help if you explained your usecase as to why you want multisite - you might not even need it.
--
Cheers
Anton
--
Cheers
Anton
what I'm trying to do
Hi,
To clarify what I'm trying to do, I basically want to create a second Drupal site with the url "indieflixs.com". I already have the test site that came ,so to speak out of the box, with the Drupal install. All I do to access that first site running on my server is http://localhost/html/; my problem is that I'm having trouble accessing the second site I created. You suggested
I interpreted this to mean that I create a symlink in my root directory and have it point to the directory of my new site (i.e. sites/indieflix.com).
When you mentioned
that made me think that I might need an index.php file in sites/indieflix.com. Is this right?
Why multisite at all?
Why do you think you need multisite?
What is wrong with two independent Drupal installs in two different directories?
I really see no need for you to even be bothering with multisite. Personally (others disagree with me) I think multisite is in most cases an unnecessary complication, and unless you understand how your webserver works and what happens to an incoming HTTP request I'd recommend avoiding it. Once you know about how webservers work and how Drupal processes an incoming request, multisite is a complete doddle to explain.
But just to clarify what you are trying to do now that you've explained it:
A site called "indieflixs.com" is hostname based site, not a subdirectory based site. So you don't need symlinks at all - symlinks are one way of rerouting a request to a subdirectory back up to the parent directory. Because your site url has no subdirectory, that redirection isn't needed.
For hostname based multisites you would create a virtual host (with the same DocumentRoot as your main site) in Apache for that URL. And you would also need to update your DNS (or just edit your PCs hosts file) to point that hostname at your server.
But getting back to your questions on (now irrelevant) subdirectory based sites:
No. The symlink lives in your root directory and points back at the root directory. It effectively mimics a whole new Drupal installation in the symlink subdirectory even though you only have one set of files.
No. There is always only one index.php file in Drupal. You need to get it out of your head that directories under /sites are web addressesable or have anything to do with web server configs / browsers etc.
The /sites subdirectories are just places to store internal Drupal settings for different urls. When Drupal (ie the index.php file back up in the root directory) processes an incoming request it looks for matching directory names under /sites to see which settings file to use. If it doesn't find a matching directory name, it will use /sites/default/settings.php file.
I'll repeat this again - those subdirectories are not web addressable and don't handle any incoming requests (there is no web server configuration for those directories). They are only used internally by Drupal (not the web server) to match the incoming url to a set of settings.
When it comes down to it all multisite is is a way for Drupal to adapt itself to the incoming requests URL. How it adapts depends on what is in each settings.php file - it could be different database connection string or some overrides to site wide variables etc.
And I'll repeat this again - the only web addressable thing in a Drupal is the root index.php file. If you really want to see that in action - turn off clean urls. The urls are all /index.php?q=node/3 or /index.php?q=taxonomy/term/5 or /index.php?q=admin/build/modules etc etc - everything is handled by index.php, and the request path itself is just an HTTP GET parameter sent to index.php.
Every request has to come through index.php - so setting up multisite is all about getting your webserver (via virtual hosts for hostnames or symlinks for subdirectories etc) to use the main index.php file for all your different multisite urls. If your webserver isn't sending the request to index.php Drupal won't be able handle it.
Stage 1 is sending every sites url to index.php (ie webserver config via virtual hosts, symlinks etc). Stage 2 is setting up the different configurations (ie inside /sites subdirectories) inside Drupal. The two stages are separate - if you find yourself trying to use web server stuff (stage 1) in your /sites directory (stage 2) you're doing the wrong thing.
--
Cheers
Anton
--
Cheers
Anton
What about Multisite Manager module?
What about the Multisite Manager module (http://drupal.org/project/multisite_manager)? Couldn't this be used to make another site working off the same codebase? Additionally, there's Multisite Maintenance (http://drupal.org/project/multisite_maintenance). Any reactions to these?
Josh McCormack
Owner, InteractiveQA
Social Network Development & QA testing
http://www.interactiveqa.com
917.620.4902
aim: jmccormciti
skype: joshmccormack
Josh McCormack
Owner, InteractiveQA
Social Network Development & QA testing
http://www.interactiveqa.com
917.620.4902
AIM:
jmccormciti
Skype:
joshmccormack
Yahoo:
joshmccormack
Google Talk:
joshmccormack@gmail.com
Windows Live
Thanks!
Thanks for all of your suggestions. I'll continue to look into other possibilities of setting up a multisite.