Website Development - Setting up a Drupal 6 Multisite on your local MAMP environment
Over the weekend I took the time to switch out our companies current local web development environment XAMPP, for the Mac OSX's native Apache/MySQL program, MAMP. This was by far an easy process as the resources I relied on were from several different documents on drupal.org, and elsewhere. As the company grows we are in need of faster alternatives for setting up a core drupal configuration, so drupal multisites was the solution for our issue.
Here I will compile all the documentation and troubleshooting tips that i relied on, and share with you how to successfully set up a drupal 6 multisite install using MAMP with separate databases. Throughout this post I will share with you a number of excellent resources, documentations regarding the setup process, explain in detail how to cleanly switch XAMPP for MAMP, and finally assist those who are trying to accomplish setting up a drupal 6 multisite installation using MAMP.
*NOTE: If you have already setup MAMP, and have not previously installed XAMPP you may proceed to step 5.
OVERVIEW
- Uninstalling XAMPP
- Installing MAMP
- Cleaning up Apache's (mis)configurations
- Configuring MAMP
- Setting up your Drupal 6 Multisite install
- Testing your Multisite installation(s)
-
Resources & helpful documentations
1. UNINSTALLING XAMPP
Upon visiting the Apache friends XAMPP site, and finding the "uninstall" link there is only 1 simple instruction, drag the "XAMPP" folder from your Mac's "Applications" into the trash, empty the trash. Sounds easy enough, however, this often leaves several traces of XAMPP in the php.ini configuration file (located in: /private/etc/php.ini). So take the alternative approach and uninstall XAMPP using Terminal with one line of sudo code.
- Open up Terminal (Search for it in spotlight, or look in your applications folder)
- When Terminal opens type: sudo rm -rf /Applications/xampp
Now you have successfully uninstalled XAMPP leaving no traces to any file referencing XAMPP... (Almost... see step 3.)
2. INSTALLING MAMP
Installing MAMP was pretty straight forward, Download the latest version from the MAMP website, here we will be working with MAMP, not MAMP Pro. In the future New Wave Media will be developing a new installation guide for setting up virtual hosts with MAMP Pro (which by the way, is a much simpler process). Once MAMP has been downloaded drag the "MAMP" file into the "Applications" folder and the installation process will begin.
- Download MAMP
- Drag MAMP into the Applications folder

3. CLEANING UP APACHE'S (MIS)CONFIGURATONS
Now before we get started with the fun stuff, there will be a few issues we should deal with before we proceed in configuring MAMP. We must first re-configure our Apache setup, so that it finds our new MAMP installation instead of our old XAMPP installation files. This was a key issue I ran into while setting up Drush, (which will also be posted about in an upcoming tutorial).
- Navigate to your php.ini file (located in: /private/etc)
-
Scroll down to line 761 or search to find the line "mysql.default_socket = " - we will want to change this to read "mysql.default_socket = /Applications/MAMP/tmp/mysql/mysql.sock" (Replace the MySQLi socket, line 797 where it reads "mysqli.default_socket" with "mysqli.default_socket = /Applications/MAMP/tmp/mysql/mysql.sock" as well.)
Now Apache is using MAMP's mysql socket layer as its default socket instead of using Apache's built in MySQL defaults, which happens to be referencing XAMPP.
- Next, we will want to replace our default ports for both mysql & mysqli with port# 3306. (Add 3306 to lines 752 & 796 - "mysql.default_port =" & "mysqli.default_port", so they read "mysql.default_port = 3306" & "mysqli.default_port = 3306").

Excellent, our Apache's php.ini file is now correctly configured so when (or if) you decide to setup Drush (which we highly recommend) your ports will be connecting with your MySQL databases correctly.
4. CONFIGURING MAMP
Now to the fun part! Initially MAMP is configured to use it's port number within the URL when navigating through your localhost, (ie. http://localhost:8888/MAMP). However it would be very nice to remove the port number for a cleaner path so we can access the same URL using http://localhost/MAMP. So to do this we must open up MAMP and change its default port number's to use Apache's default port numbers (80 - Apache & 3306 - MySQL), hence the port number we used in the previous step.
- Open up MAMP
- Select Preferences, Ports and click the "Set to default Apache and MySQL ports" button and then select "Ok"
- Your ports should now read 80 & 3306.
- Next you will want to locate your local web development folder, (htdocs) and select this as Apache's Document Root. So go back into Preferences, select the Apache tab and set up your Document Root. In our case this looked like: "/Users/newwavemedia/Sites/htdocs", yours may differ, obviously you would need to change out "newwavemedia" with your personal username.
- Stop & Start your MAMP servers.
- Navigate to http://localhost/MAMP and you should now have a cleaner URL without the port numbers. Navigating to: http://localhost should show you a directory listing of all your sites, accessing a site by the URL: http://localhost/you-sites-folder-name.


5. SETTING UP YOUR DRUPAL 6 MULTISITE INSTALL
Alright, So we've now uninstalled XAMPP, Installed MAMP, cleaned up Apache's configuration files, and finally configured MAMP to support a cleaner URL by changing its default port numbers.
Now we can get into the exciting part and actually start running multiple drupal installations using a single Drupal core set of files, and install site specific modules/themes in seperate databases. So basically we are reusing the main part of drupal, so instead of updating drupal core across 100 different sites, we now only need to update it on 1. We can also share modules across sites by placing our modules in the /sites/all/modules folder (same for any themes), but still have the flexibility to add those "site specific" modules to our /sites/multisite/modules folder.
- First things first, Ensure you have a properly configured drupal 6 site installed using its own database. (From here on we will take the assumption that you have setup a Drupal 6 site before and have connected to the MySQL database correctly and installed drupal's core).
- Inside of your sites main folder with all your drupal core files, navigate to the: /sites/ folder. Here is where we will begin to setup our multisite installation.
-
Create 2 folders inside of this folder; "multisite-1" & "multisite-2" are the names of our folders.

-
Inside of each folder make a copy of your sites "settings.php" file and paste it into each. So you should have a file structure that follows; /sites/multisite-1/settings.php & /sites/multisite-2/settings.php.
- Now we will setup our 2 databases which will host our multisite installations. In your browser navigation to: http://localhost/MAMP/ and select the "phpMyAdmin" tab. Create a database that you will recognize, we usually stick with something that corresponds to our multisites folder, so we setup 2 databases called "multisite-1" & "multisite-2".
- Next, we will open up each settings.php file and set our database connections to use the ones we setup in the previous step. (Note: If you were previously using XAMPP, you will need to change the username/password to read: root:root@localhost/databasename. As a default XAMPP doesn't use a password for the admin user (root)).
-
Now we will setup our hosts file (located in: /private/etc) so we can reference our multisite's installation through our browsers URL. Below the default hosts;
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhostAdd the following lines;
# DRUPAL HOSTS
127.0.0.1 multisite-1
127.0.0.1 multisite-2This will enable us later on to use "http://multisite-1/multisite-main/install.php" to setup our drupal multisites.
- It's time to start adding in some virtual host references to our drupal multisites. Open up your httpd.conf file (located in: /private/etc/apache2). Search for the block "# Virtual hosts", near the end of the document. Uncomment the line below so it reads; Include /private/etc/apache2/extra/httpd-vhosts.conf.
-
Find the file we reference above; httpd-vhosts.conf. You can locate this in: /private/etc/apache2/extra. We will need to add the following code blocks, one for each multisite we want to setup, in our case 2, one for multisite-1 and another for multisite-2
Ensure line 19 read's: NameVirtualHost *:80
Proceed down below and add in the following after the example VirtualHost comments;
<VirtualHost *:80>
DocumentRoot "/Users/newwavemedia/Sites/htdocs/multisite-main"
ServerName multisite-1
</VirtualHost><VirtualHost *:80>
DocumentRoot "/Users/newwavemedia/Sites/htdocs/multisite-main"
ServerName multisite-2
</VirtualHost>*So one thing to note here is that the DocumentRoot path ends in "multisite-main" this is the folder of your MAIN drupal installation that you put your 2 multisite folders in (ie. /htdocs/multisite-main/sites/multisite-1 & /htdocs/multisite-main/sites/multisite-2). You may need to change this accordingly.
-
Now we are almost finished the setup, we just need to install our new drupal databases and then test our multisite installations. This was the part that can be very confusing to the beginner drupal user. Many guides say to navigate to "http://multisite-1/install.php"; however, this will return a "Page Not Found" error.
What you need to do to successfully find your installation is to type in; http://multisite-1/you-main-drupal-folder, so in our particular install this would be; http://multisite-1/multisite-main/install.php.
Go ahead and proceed with the multisite-1 & multisite-2 installations by using your browser's path's accordingly.

*CONGRATULATIONS YOU'VE NOW SETUP YOUR FIRST MULTISITE INSTALLATION.
6. TESTING YOUR MULTISITE INSTALLATION(S)
Now that we have successfully setup both our multisite installations (1 & 2), we can proceed to test our installation to see how this will benefit us in the future for accomplishing tasks much quicker between sites that rely on the same code base or share similar modules & themes.
- Download the latest version of your favorite drupal 6 module. Here we will be using "Views".
- Place the "Views" module inside of your main sites drupal modules folder: multisite-main/sites/all/modules/views, this module will now be shared across all multisite installations. Same goes for any themes you setup in the /sites/all/themes folder. You may now enable it for individual sites by visiting your sites "admin/build/modules" page. (ie. http://multisite-1/multisite-main/admin/build/modules).
- Likewise, if you do not want to share modules/themes across sites you would create a "modules" or "themes" folder inside of your multisite-1 or multisite-2 folder, and place your site specific modules inside of them.
7. RESOURCES & HELPFUL DOCUMENTATIONS
Uninstalling XAMPP:
Installing MAMP:
Cleaning Up Apache's (mis)Configurations:
Configuring MAMP:
Setting up your Drupal 6 Multisite install:
- August 30th, 2010
Search the Blog!
Other Posts from admin
Similar Posts
Popular Blog Posts
-
9,468
-
6,389
-
6,136
-
6,075
-
5,682
-
5,660
-
5,601
-
5,423

