I found this: http://drupal.org/node/290768

But is this what I need to follow? I've got D6.16 installed and running on my Ubuntu10.04 from an apt-get install (base dir is /usr/share/drupal6/...). What I want is to be able to work on/develop multiple practice sites on my home (non-live) computer. For normal multiple website practice I've already got a public_html directory, plus a couple symlinks in /var/www/ to my home dir, but I'm sure that's not right for multiple Drupal sites....

Comments

cog.rusty’s picture

Why not? They are complete Drupal sites, with their own database, administrator, available and enabled modules and themes, everything.

Olwe’s picture

I'm still confused. I went to "10 Minute Multisite Install & Configuration" (http://drupal.org/node/138889#comment-2510252) and it says:

You now have a basic unconfigured Drupal6 installation using the database drupal6 and accessible at http://www.example.com/drupal6. Do not use it. This is the "prototype" installation that we will use to create the sites we really want to use.

I'm on a home computer (Ubuntu 10.04) with LAMP installed properly, drupal6 apt-got, database setup fine ... but I don't know anything about http://www.example.com. My local Apache2 webserver goes to http://localhost or http://127.0.0.1 How can I make a browser see drupal at http://www.example.com? I'd like that, then I'd like to have other sites on my home machine, such as http://another_drupal_site_1.com, http://another_drupal_site_2.com, etc. I've seen various install/config guides, but they all seem to bypass this basic issue.

cog.rusty’s picture

To use domain names like http://example.com locally on your computer for vhosts which you have set up, you can edit your /etc/hosts file and add, for example:

127.0.0.1  example1.com
127.0.0.1  example2.com
127.0.0.1  example3.com

But better don't do that because it may be confusing later when you try to access an online site and you get a local one. Instead of that, you can use domains like

127.0.0.1  example1.local

Those names are the ones supposed to be used in the examples in that guide, in ServerName:

ServerName example1.local  //[your vhost#1 name]
Olwe’s picture

So I should create a file called drupal in /etc/apache2/sites-available/ and it should be based on the example ...

#
# Virtual hosting configuration for Drupal
#


ServerAdmin [your email address]

DocumentRoot /usr/share/drupal6/
ServerName [your vhost#1 name]
ServerAlias [if you want to support www.example.com and example.com]
RewriteEngine On
RewriteOptions inherit


ServerAdmin [your email address]

DocumentRoot /usr/share/drupal6/
ServerName [your vhost#2 name]
ServerAlias [if you want to support www.example1.com and example1.com]
RewriteEngine On
RewriteOptions inherit

[...repeat for all your vhosts]

So what is the ServerName supposed to be? Let's say I want to work on 3 separate sites at home. You're saying call them something1.local, something2.local, and something3.local in this file. What about the ServerAlias? Is that just for leaving off www.? What should the DocumentRoot be? I understand I need to create separate directories in /usr/share/drupal6/sites right? How will this know that something1.local means "go use the stuff in .../drupal6/sites/something1/ ? And I guess I should also let /etc/hosts know about something1.local, something2.local and something3.local like 127.0.0.1 something1.local

Very confusing!

cog.rusty’s picture

In the server configuration part, there are no separate subdirectories for your different Drupal sites. Just different domain names, which all point to the same directory where Drupal's index.php file is.

DocumentRoot specifies the disk directory where you want your vhost to look. In this case it will always be

DocumentRoot /usr/share/drupal6

for all Drupal sites, since that is where Drupal's index.php file is located.

ServerName is the domain name of your site. For a site at http://example1.local you would use

ServerName example1.local

ServerAlias can be used for alternative domain names served by the same vhost. Using that, you can make this one vhost serve all your Drupal sites, so that you don't have to create more vhosts:

ServerAlias www.example1.local example2.local example3.local

and you are done. No more vhosts with their own ServerNames are needed, which is a reasonable thing to do because they all use the same DocumentRoot (drupal).

---------

That was the server part. Now, how Drupal will tell apart the sites based on the browser's request, and where it will store each site's stuff, that is what the link in your first post explains.

--------- EDIT:

Oops. No, wait. There has been a mix-up here. The first article is about installing Drupal "in the normal way", by uploading it from drupal.org. The second one is about using the Ubuntu installer, which splits and stores Drupal in many different places. The principles are the same but the paths are different. In a "normal" install, your document root would be /var/www/drupal or wherever you uploaded drupal.

Olwe’s picture

So this is what I've done so far: I've got a file in /etc/apache2/sites-enabled/ called drupal

#
# Virtual hosting configuration for Drupal
#


ServerAdmin webmaster@localhost

DocumentRoot /usr/share/drupal6/
ServerName practice1.local
#ServerAlias [if you want to support www.example.com and example.com]
RewriteEngine On
RewriteOptions inherit


ServerAdmin webmaster@localhost

DocumentRoot /usr/share/drupal6/
ServerName practice2.local
#ServerAlias [if you want to support www.example1.com and example1.com]
RewriteEngine On
RewriteOptions inherit

I've left the ServerAlias commented because I'm not worried about www.practice1.local and practice1.local resolution. I did the apache reload. I then created directories /usr/share/drupal6/sites/practice1.local and /usr/share/drupal6/sites/practice2.local and copied the contents of .../sites/default/ into them.

Now comes the critical part: 1) What do I do with /etc/hosts? I've tried various things that don't work; when I go to http://practice1.local or http://practice2.local nothing happens, the browser just sits there. (I guess that's sort of good because it's not going out on the Web and looking.) I can map 127.0.0.1 (or any 127.0.x.x) to a practice3.local in /etc/hosts (without apache sites-enabled stuff for practice3.local) and it takes me to the default apache webserver page just fine. So what should /etc/hosts have now? And 2) how does any of this know about my new directories .../sites/practice1.local and .../sites/practice2.local?

Very frustrating. Lots of conflicting advice and info. For example: http://drupal.org/node/278 has a vague reference to apache tweaking. The CPanel version is totally useless. I have not changed the settings.php files in the new sites' directories, because the 10-Minute Guide says it's not necessary, while the Multi-Site on Linux says do it. Even in the 10-Minute Guide the first guide and the "manual guide" conflict on what to do with Apache.

cog.rusty’s picture

Assuming that Drupal is really installed in /usr/share/drupal6

Never write in /etc/apache2/sites-enabled
In /etc/apache2/sites-available:

...
...
# Lose the trailing slash here:
DocumentRoot /usr/share/drupal6
ServerName practice1.local

# All your drupal sites are here:
ServerAlias practice2.local practice3.local

# This should enable the use of .htaccess files
AllowOverride All
...
...
# No more vhosts, no more ServerNames. Just this one covers all your drupal sites.

Enable this vhost file:

sudo a2ensite /etc/apache2/sites-available/drupal

To make your machine recognize the domain names, edit /etc/hosts:

127.0.0.1  practice1.local
127.0.0.1  practice2.local
127.0.0.1  practice3.local

Restart apache

sudo /etc/init.d/apache2 reload

You are done with the server.

Now, how can Drupal tell the sites apart: All sites hit Drupal's index.php file. Drupal wakes up and reads the HTTP_HOST from the URL which you typed in your browser to get there. It compares it with the names of the directories under sites/. If it finds a match, it brings up the right site. If not, it uses sites/default.

Make sure that the settings.php files which you copied under sites/sitename/ are fresh unmodified copies of default.settings.php. Then, browsing to any site should bring up Drupal's installer for that site.

Olwe’s picture

Two errors come up after I change .../sites-available/drupal:

# /etc/init.d/apache2 reload
Syntax error on line 11 of /etc/apache2/sites-enabled/drupal:
AllowOverride not allowed here
...fail!

I comment it out and it gives this error (the old error:

/etc/init.d/apache2 reload
* Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

/etc/hosts are as you advise.

cog.rusty’s picture

AllowOverride belongs inside a Directory section:

<Directory /usr/share/drupal6>
  ...
  Options +FollowSymlinks
  AllowOverride All
  ...
</Directory>

About "Could not reliably determine", it usually means that you haven't set the ServerName line or maybe there is a spelling error in "ServerName".

-------- Edit:

Also, unlike what that guide says, DocumentRoot and that Directory are normally /var/www/drupal6

Olwe’s picture

Good. Made the change to the .../sites-available/drupal file:

#
# Virtual hosting configuration for Drupal
#

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /usr/share/drupal6

    <Directory /usr/share/drupal6>
        AllowOverride All
    </Directory>
    
    ServerName practice1.local
    ServerAlias practice2.local

    RewriteEngine On
    RewriteOptions inherit
</VirtualHost>

I do the # /etc/init.d/apache2 reload
and get the same error:
* Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

There are no misspellings. I can remove the drupal symlink in .../sites-enabled, redo apache2 reload and get the same error. Put the symlink back in with a2ensite, same error.

Meanwhile in my browser http://practice1.local just brings up a white page. http://practice1.local/drupal6/install.php just sits there white page. Curiously, If I change /etc/hosts to 127.0.1.1 practice1.local and 127.0.1.1 practice2.local, the browser at http://practice1.local goes to the apache default page (It works!...), but http://practice2.local goes to blank white page. Then back to http://practice1.local/drupal6/install.php -- blank, white page! Switch /etc/hosts back to 127.0.0.1 for both practice1.local and practice2.local and the error comes back!

Here's my /etc/hosts:

127.0.0.1       localhost
127.0.0.1       practice1.local
127.0.0.1       practice2.local
127.0.1.1       mycompter
127.0.1.2       gfhome.local


# The following lines are desirable for IPv6 capable hosts                                                                        
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

The reload seems to complain about ServerName with or without the .../sites-available/drupal symlink, but if /etc/hosts is changed (127.0.1.1 instead of 127.0.0.1 for practice1.local ...) the ServerName complaint goes away! How can that be?

Could this be an Ubuntu-Debian package issue? I had the same craziness with a language and Emacs major-mode fight; the language I hand-installed, the major-mode I apt-got -- and I finally had to go totally hand-installed for both.

Sorry for all the confusion....

cog.rusty’s picture

Then 127.0.1.1 may be the right one for your system. It depends.

About ServerName, does it change anything if you move up ServerName and ServerAlias and place them next to DocumentRoot, and not after all those other directives?

Olwe’s picture

No, moving didn't help. But then 127.0.1.1 in /etc/hosts for practice1 and 2 only gives me regular http://localhost/ behavior (goes straight to "It works!" screen) and can't even see .../drupal6/install.php, AND practice2/ doesn't even do It works! But then http://localhost/drupal6/install.php does work. Very weird. Anyway, I've asked a LUG for assistance. The ACLUG is a bunch of old debian sys admins. If they don't know how to manage this unruly Ubuntu behavior, it's hopeless....

cog.rusty’s picture

What about

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /usr/share/drupal6
  ServerName practice1.local
  ServerAlias practice2.local

  <Directory /usr/share/drupal6>
    DirectoryIndex index.php index.html
    Options +FollowSymlinks
    AllowOverride All

    RewriteEngine On
    RewriteOptions inherit

    Order allow, deny
    Allow from all
  </Directory>

</VirtualHost>
Olwe’s picture

Same old same old. BTW, it doesn't like the space between allow,deny for Order.

lordrt21’s picture

do you use linux for everyday tasks or only for the drupal? if for the latter one only, then i would suggest to run linux on a vm, and then using winscp to handle all the drupal files etc... i personally use windows as os, but all my drupal sites run on a single vm using LAMP and no prob so far

Olwe’s picture

I'm exclusively on Linux Ubuntu 10.04. Maybe I should bail to Win7 if this can't be done on Linux before insanity rears its ugly head....