I'd like to run all my Drupal 6 sites as a multisite installation. I have that set up just fine on my remote host. (They have a panel-based admin tool that made it fairly easy.) Now I want to mirror the installation on my Mac OS 10.5 laptop to make development easier.

So I have a single Drupal installation at ~/Sites/drupal. I plan to have individual folders at ~/Sites/drupal/sites -- for example, ~/Sites/drupal/sites/tomgeller.com, ~/Sites/drupal/sites/gellerguides.com, etc. And MAMP points to ~/Sites/drupal as my docroot. So my question is: How do I set this up so I can access each of the sites via a Web browser on my localhost machine? (I assume URLs will be something like http://localhost/tomgeller, http://localhost/gellerguides, etc.. But of course I'll do whatever works best.)

I read the text in settings.php, and but that either doesn't solve the problem, or I'm missing something. I'm guessing I have to do something to httpd.conf, yes?

All help will be appreciated. Many thanks,

Comments

zeta ζ’s picture

You need to set up virtual hosts that point to your installation ~/Sites/drupal , called something local like gellerguides, that would be available at http://gellerguides and drupal would automatically use ~/Sites/drupal/sites/gellerguides (no .com – it’s local).

You could prefix all vitual hosts with ‘local’ if you want.

I have this with Apache on linux, so I guess would work on Mac too.

Sample vhost for Apache

<VirtualHost *:80>
ServerAdmin root@localhost
DocumentRoot "/var/www/localhost/Sites/drupal"
ServerName gellerguides
<Directory "/var/www/localhost/Sites/drupal">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>

If you also make a virtual host (pointing to your installation) called admin.gellerguides , you will be able to visit http://gellerguides And http://admin.gellerguides at the same time, giving you two cookies – so independent users. This would mean you can administer the login workflow (and everything else) and test logging in, without having to continually log out of admin in order to test the setup.
___________________
It’s in the detaιls…

demonstration portfolio

tgeller’s picture

I changed the DocumentRoot and Directory paths (of course) and tried it. http://gellerguides then didn't go to my gellerguides site, although http://localhost did, despite MAMP indicating that the docroot was ~/Sites (!).

I tried a few other options, such as using trailing slashes, uncommenting the "NameVirtualHost *" line, and changing the first line to "", but with no luck. Any other suggestions?

Thanks,

---
Tom Geller * San Francisco
SaveMyHomeBook.com (Drupal!) * TomGeller.com (not Drupal)

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

zeta ζ’s picture

If http://gellerguides doesn’t work, it isn’t using the virtual host defined by this: editing any of it is futile until it is recognised, as indicated by http://gellerguides working.

Did you restart Apache?
___________________
It’s in the detaιls…

demonstration portfolio

tgeller’s picture

I did restart Apache.

---
Tom Geller * San Francisco
SaveMyHomeBook.com (Drupal!) * TomGeller.com (not Drupal)

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

brenda003’s picture

Do you have a hosts file on a Mac? This is an easy fix on Linux, in my /etc/hosts file I just pop in the various other "domains". So for example it would have:

127.0.0.1 localhost
127.0.0.1 gellerguides

etc. Then the above should work.

Oh, here's some info: http://docs.info.apple.com/article.html?artnum=88158

tgeller’s picture

See http://drupal.org/node/120647 for good, step-by-step instructions that I'd missed before. Gah.

Brenda: Your suggestion helped! So far, so good: It's redirecting to the two separate, complete Drupal installations. Now the next step is to test it out with a true multisite installation (i.e., one Drupal install with separate sites under ~/[Drupal]/sites). I'll do that later and report back if there are further problems. But for now, I think the problem's solved.

There's still a small quirk, which you're welcome to try to suss out... but please don't feel obliged. In short: http://localhost should go to a directory listing page that shows the two directories, ~/Sites/gellerguides and ~/Sites/drupal, as the docroot (set in MAMP) is ~/Sites. HOWEVER, instead it gives the Drupal site at ~/Sites/drupal.

Here's the situation.

  • The ~/Sites directory contains two subdirectories: "drupal" and "gellerguides".
  • In MAMP, the docroot is set in the Apache preferences as ~/Sites.
  • The /private/etc/hosts file contains "127.0.0.1 localhost", "127.0.0.1 drupal", and "127.0.0.1 gellerguides".
  • The following code is now in the httpd.conf:
    NameVirtualHost *
    
    <VirtualHost *:80>
    	ServerAdmin root@localhost
    	DocumentRoot "/Users/tgeller/Sites/drupal/"
    	ServerName drupal
    	<Directory "/Users/tgeller/Sites/drupal/">
    		Options Indexes FollowSymLinks
    		AllowOverride All
    		Order allow,deny
    		Allow from all
    	</Directory>
    	<IfModule mpm_peruser_module>
    		ServerEnvironment apache apache
    	</IfModule>
    </VirtualHost>
    
    <VirtualHost *:80>
    	ServerAdmin root@localhost
    	DocumentRoot "/Users/tgeller/Sites/gellerguides/"
    	ServerName gellerguides
    	<Directory "/Users/tgeller/Sites/gellerguides/">
    		Options Indexes FollowSymLinks
    		AllowOverride All
    		Order allow,deny
    		Allow from all
    	</Directory>
    	<IfModule mpm_peruser_module>
    		ServerEnvironment apache apache
    	</IfModule>
    </VirtualHost>
    
    

End of puzzle. :) Anyway, I'll post again if I can't get multisites working correctly, but I think your (collective) suggestions solved the problem. Thanks, everybody!

---
Tom Geller * San Francisco
SaveMyHomeBook.com (Drupal!) * TomGeller.com (not Drupal)

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal

zeta ζ’s picture

You need a default vhost for localhost as well (first one defined is the default, I think).
That’s why localhost points to /Users/tgeller/Sites/drupal/
___________________
It’s in the detaιls…

demonstration portfolio

tgeller’s picture

That makes a lot of sense -- it's working perfectly now. Thank you!

---
Tom Geller * San Francisco
SaveMyHomeBook.com (Drupal!) * TomGeller.com (not Drupal)

---
Tom Geller * tomgeller.com * Oberlin, Ohio
See my lynda.com videos about Drupal