It only took me four hours to do what should have taken less than half an hour. I finally figured out how to make multiple sites work. I'm a newbie. Thought I'd share.

First I did a single local Drupal install using this guideline: http://drupal.org/node/66187. (*See note at bottom.) This is for MacOS X. It uses MAMP. I am running everything on my own Mac computer. Eventually, of course, I will need to put my web sites on the internet. I've learned a lot in the process of getting my local installation working to help with that later.

Next, I wanted a play and experimentation site (my default Drupal site), but I also wanted to start working on a couple of real web projects: 1) blog and 2) teaching site.

After the first installation, there are four basic steps to getting multiple sites to work. I include below all the little tricks I had to figure out. What actually needs to be done is simple. Getting it to work was not simple, given that I am not a programmer, don't know unix, am not comfortable in a terminal window -- and the documentation on multiple sites is a morass.

1) Set up new folders in the Drupal sites directory (/applications/mamp/htdocs/drupal/sites) and copy in a brand new settings.php file (copy from the default.settings.php file in the default folder -- where your initial installation is) for each. See http://drupal.org/getting-started/5/install/multi-site.

Note: your folder names have to be the same as the "server names" you will set up later in the /etc/hosts file. I used:
blog.drupal.local
teaching.drupal.local

So for each site, I created a new folder and copied in a new settings.php file:
sites/blog.drupal.local/settings.php
sites/teaching.drupal.local/settings.php.

You also have to change permissions so Drupal can access these settings files. In a terminal window:
cd /applications/mamp/htdocs/drupal/sites
chmod o+w blog.drupal.local/settings.php
chmod o+w teaching.drupal.local/settings.php

I will add modules and themes folders later as needed.

2) Change the web server settings. See:
http://drupal.org/node/238805
http://www.entityarts.net/blog/steve_krueger/07-19-2007/virtualhosts_mam...

I changed two files on my system as follows:

To change the /etc/hosts file:
Use terminal. (Note: this file is not findable through the Finder.)
cd /private/etc; sudo nano hosts
Give your system password and use the nano editor to make your changes. (See the control commands at bottom.)
I added below 127.0.0.1 localhost:
127.0.0.1 drupal.local
127.0.0.1 blog.drupal.local
127.0.0.1 teaching.drupal.local

Change the /applications/mamp/conf/apache/httpd.conf file. Open it in a text editor. Scroll to the bottom. Add a virtual host. I added:

<VirtualHost *>
	ServerName drupal.local
	ServerAlias *.drupal.local
	DocumentRoot /applications/mamp/htdocs/drupal/
</VirtualHost>

Save the file.

Now use Mamp to RESTART the servers (Apache and MySql). You don’t have to turn off the Mamp application, just use the little panel. It asked me for system password each time to stop.

3) Create databases for each of the new web sites in MySql. Go to the Mamp start page (in your browser) and follow the directions from the original install guide: http://drupal.org/node/66187 to add a new database for each additional site. I named my new databases drupal_blog and drupal_teaching. I had to add a new user also for each new database since privileges are database specific. I named them tgustilo2, tgustilo3 with the same password for everything. (My original database was drupal1 with user tgustilo.)

4) Browse to each new site and the install.php will run automatically. Go through the same process as you went through with your initial install.
http://blog.drupal.local
http://teaching.drupal.local
Type in the info as requested for the name of your database and your db user and password, etc.
Once each site is installed, you are taken to the configuration page. Voila!

NOTE - REFERENCE

I’ve created a bunch of different users in this process. I gave them all the same password.

Each web site has an admin user: admin
Each database has a user: tgustilo (for drupal1), tgustilo2 (drupal_blog), tgustilo3 (drupal_teaching). Use Mamp phpMyAdmin tool to see databases and users.
The mysql installation itself also has a user: root, for which I changed the original password per the install directions - see above. (This was done for the first install.)

Last, I wrote all this down so I never have to figure it out again!

* The only trouble I had with these directions was changing the password for the mysql user root, root. (There is a warning to change it.)
For the first command, put your newpassword at the end of the line. (This is not indicated.) You will be prompted for the current password ("root").
For the second part, open each file in a text editor and change the "root" password to your new password where called for in the file.
(It would be good if somebody edited node/66187 to reflect this.)

Comments

timothysutton1’s picture

Running OSX 1.4 and Drupal 6

Done everything you say but still error:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Firefox can't establish a connection to the server at lambethopen.drupal.local.
Though the site seems valid, the browser was unable to establish a connection.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I'm trying to run two multi sites whose settings.php files are in in folders

Applications/MAMP/htdocs/drupal/sites

and named

lambethopen.drupal.local
test.drupal.local

etc/host:

127.0.0.1       localhost
127.0.0.1       drupal.local
127.0.0.1       lambethopen.drupal.local
127.0.0.1       test.drupal.local
127.0.0.1       testdir
255.255.255.255 broadcasthost
::1             localhost

code added to bottom of httpd.conf file:

NameVirtualHost *

<VirtualHost *>
ServerName drupal.local
ServerAlias *.drupal.local
DocumentRoot /applications/mamp/htdocs/drupal
</VirtualHost>

Document Root for MAMP is:

/Applications/MAMP/htdocs/drupal

I have checked, re-checked and double checked. Any ideas where I might be going wrong?

Thanks

Tim

tgustilo’s picture

Hi Tim,

My son tried my directions and had some trouble also. He found he had to change this setting (from the instructions here: http://drupal.org/node/66187) --

Clean up your Localhost URL

If you would like to shorten your URL from "http://localhost:8888" to "http://localhost" follow these instructions:

* Open the MAMP application
* Click on "Preferences" and then "Ports"
* Change the Apache Port to 80 (the standard web server port)

In MAMP PRO, change the port of apache to 80 and click on apply.

Hope this helps.

jouflas’s picture

Thanks for great instructions. I couldn't get it to work until I remembered that with MAMP Pro the httpd.conf file must be edited using the FILE->EDIT TEMPLATES command within MAMP Pro. Did it... works great!

annakjonsson’s picture

Nice set of instructions, and it worked as you said. Thanks for laying this out in newbie terms!

Visitor82’s picture

I have managed to set up a local site, build it and take it live. Now I want to build a second site locally. I purchased MAMPPRO, followed these nicely written instructions but cant get it working.

I think my problem may be as simple as the fact I originally installed drupal straight inside htdocs and not a folder inside htdocs, eg my sites folder is htdocs/sites not htdocs/drupal/sites, thus rendering all the helpful posts useless to me.

Does this sound like it is a problem and can I fix it without a lot of pain ???

matt_harrold’s picture

In the instructions for changing the http.conf file ... simply change:

DocumentRoot /applications/mamp/htdocs/drupal/

to

DocumentRoot /applications/mamp/htdocs/

The rest of the instructions should still apply.

Visitor82’s picture

Hey thanks a lot Matt, that got me started. I had a few other issues to fix after this advice but I'm there now. Much appreciated. Warwick

motomaki’s picture

Thanks tgustilo!
I am noob on drupal and I had been trying to do this for a week. I have read numerous complicated/advanced setups from various posts that are difficult to understand for noobs. It took me 30 mins to set it up using your simple step by step setup. Thanks for writing this post its appreciated! Am adding links to your post for other noobs am working with. thanks again!

dinomight’s picture

Thanks so much for this fantastic tutorial! I finally have a multi-site running on my local server, and at first glance it appears to be working perfectly. I basically was in the same situation as you. As you said: "Getting it to work was not simple, given that I am not a programmer, don't know unix, am not comfortable in a terminal window -- and the documentation on multiple sites is a morass."

I was worried that my experimental site that I'm using simply to learn the program would not appear without making a special folder for it, but it works just fine. It probably took me about an hour to actually make everything work right, but I think it was just an issue with making sure everything was named properly.

I should also point out that the install.php file did not run until I specifically added it to the url in my browser. My site is totfmcoaches.totfootball.com, but this address produced a white screen, so I just changed the address to totfmcoaches.totfootball.com/install.php and it worked great.

Thanks again for simplifying the instructions for us non-programmers. I think this tutorial should be in the main multi-site documentation.

melissa23’s picture

wish i had seen this a long time ago, would have save me a mountain of troubles

ralexanderclark’s picture

http://www.youtube.com/watch?v=Ap-tAeSV4Z8

I followed the written instructions word for word with no luck. Here is a video that helped me. Hope this helps.

kristin.e’s picture

Hi - thanks for the tutorial. I did get it mostly working - BUT

now I can't navigate to pages on my original site most of the time - I keep getting 404 Page not found errors unless I navigate to ?q=user. But after that - any link I click gives me the dreaded 404. What could be the problem?

I did manage to install my second site but I did notice that it stated the my system didn't support clean URLs - could this have something to do with it? I had enabled clean URLs on my original site.

I am really stumped!

Thanks in advance...

UPDATE:
...I fixed this issue by editing the httpd.conf file as per http://drupal.org/getting-started/clean-urls. sorry this is another issue altogether and not related to this post but some of you may find that your clean urls aren't working after creating multisite so this may help too.

criscom’s picture

It's been a while since this tutorial was posted and it got me going. Great write up.

Times change and so do OS and Drupal versions. Now it seems even easier to set up your perfect development environment. No messing up with the /applications/mamp/conf/apache/httpd.conf file anymore.

My environment:
MAMP Pro 2.1.1
Drupal 7.22

In my /Applications/MAMP/htdocs folder, I have a folder "mydrupalsite" that holds my drupal install.

In ~/etc/hosts set up your localhost as described above. I put this in: 127.0.0.1 mydrupalsite.local

Then in MAMP Pro go to hosts click the plus sign at the bottom of the window and add a new host. In "Servername" give it the same name as you entered in the ~/etc/hosts file: mydrupalsite.local and in storage (Speicherort in German) enter the path to the folder that holds your drupal install in htdocs: /Applications/MAMP/htdocs/mydrupalsite

Navigate to mydrupalsite.local in order to set up your drupal site.

I haven't tried it yet but you can host multiple sites locally with one drupal install by first defining more hosts in the ~/etc/host file and fork them in sites.php.