Installing Drupal on Mac OS X 10.5 Leopard

I thought I'd write up the steps I took to get Drupal running on a stock Leopard installation. You may wish to save some time and install MAMP instead. Especially if you need GD support (i.e., you're going to have Drupal do image resizing). Update 17-Dec-2007: In fact, I recommend using MAMP instead.

Step 1: Enable PHP

Uncomment line 114 in /etc/apache2/httpd.conf to enable Leopard's built-in PHP:

LoadModule php5_module        libexec/apache2/

Start Apache 2 by using the Sharing panel in Preferences or at the command line with the following:

sudo apachectl start

(If Apache was already running, use restart instead of start.)

Place a test document into the default htdocs root to see if php is running. I created /Library/WebServer/Documents/phpinfo.php with the following content:

<?php phpinfo(); ?>

Now going to http://localhost/phpinfo.php shows me the info page for PHP 5.2.4. Yay!

Step 2: Friendly Virtual Hosts in Apache

I don't like keeping my websites in /Library/WebServer/Documents. It's a cumbersome place; I'd much rather keep them in /Users/john/Sites. That's right in my home directory and when I copy or sync my home directory I get the sites I'm working on, too. But using Leopard's built-in URL support for my home directory is verbose, too:


I'd much rather use a nice short URL like http://dev/sitename. So first I assigned the name dev to my computer by adding a line to /etc/hosts:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
## dev localhost broadcasthost

Since Leopard caches DNS queries, we force it to reread /etc/hosts by using dscacheutil which replaces the lookupd utility that was in OS X 10.4.

dscacheutil -flushcache

I changed /etc/apache2/users/john.conf from

<Directory "/Users/john/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all


<Directory "/Users/john/Sites/">
    Options Indexes MultiViews FollowSymLinks
    # Allow .htaccess files to override httpd.conf.
    AllowOverride All
    # No access allowed.
    Order deny,allow
    Deny from all
    # Except from this machine.
    Allow from

# Enable virtual hosts.
NameVirtualHost *:80

# Point virtual host to our directory.
<Virtualhost *:80>
    DocumentRoot /Users/john/Sites
    Servername dev

You can test that everything works and you didn't make any typos by using

sudo apachectl configtest

which should tell you that the syntax of your Apache configuration files is OK (it will point you to the line containing the error otherwise). If all is OK, restart Apache to effect the changes:

sudo apachectl restart

Now you should be able to go to http://dev/ in your browser, and the file at /Users/john/Sites/index.html should be displayed.

Installing MySQL

There was no friendly installer for OS X 10.5 so I used the OS X package for 10.4. It ran fine.

It was unclear from my web searches whether the startup item for MySQL is working on Leopard. So I created the following file at /Library/LaunchDaemons/com.mysql.mysqld.plist to autostart MySQL (thanks Joannou Ng):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Before I restarted, I wanted to make sure that mysql would be in my PATH environment variable when I restart. So I created a file at /etc/paths.d/mysql containing


For more information on this, type man path_helper.

Then I restarted to make sure that MySQL would launch. Yes, it's running:

ps -ax | grep my
   40 ??         0:00.01 /bin/sh /usr/local/mysql/bin/mysqld_safe
   88 ??         0:00.11 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/local/mysql/data/

Now to set it up securely.


This allows you to set a root password, disallow remote root logins, and generally tighten up MySQL security.

It's nice to be able to tweak MySQL parameters, so I created a my.cnf file:

sudo cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf

The only thing I tweaked in the my.cnf file was to add one line under the [mysqld] heading to prevent MySQL from listening on port 3306 (I don't like unnecessary open ports):


Now I can create a database for Drupal to use:

mysql -uroot -p
mysql> CREATE DATABASE drupaldb;
Query OK, 1 row affected (0.00 sec)

One more thing. PHP and MySQL are confused about which socket to use (/tmp/mysql.sock vs. /var/mysql/mysql.sock). So let's provide a symlink so they can use either one:

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Installing Drupal

Pull down a copy of Drupal 5 from the CVS repository:

cd ~/Sites
cvs -z9 checkout -r DRUPAL-5 drupal

Change permissions on the settings file so the installer can modify it:

chmod o+w drupal/sites/default/settings.php

Run the Drupal installer by going to http://dev/drupal.

Remove the permissions from the settings file:

chmod o-w drupal/sites/default/settings.php

And create Drupal's files directory:

mkdir /Users/john/Sites/drupal/files
sudo chown www /Users/john/Sites/drupal/files


Now I've got an easy setup where I can create my Drupal sites under /Users/john/Sites and refer to them with short names like http://dev/foo. MySQL is running nicely. Public access to my dev sites is disabled by Apache. Life is good.


Wow! I am glad I Googled your blog. I thought I knew how to install MySQL but was baffled under Leopard. Thanks for the research effort and the great help!


You're welcome, Andy. But. After dragging my feet for a long time and insisting on doing things the "native" way, I'm now a big MAMP fan for development.

Unfortunately the PHP version that ships with 10.5 does not include GD support. This means that you'll need to build your own, unless there's a package for it somewhere.

Hey John. Thank you so much for this excellent tutorial. Everything went very smoothly.

If you haven't already, i'd appreciate you expanding a bit on why you prefer MAMP over this method. I, for one, don't see the value of downloading and installing a 127MB framework to do something that is already supported (semi) natively. I recognize this is a naive viewpoint, and i'd love to hear more on this issue.

Thanks again for this tutorial. It was very clear and helpful.

Leopard's built-in PHP does not support dynamic extensions or PECL. So when you want to use APC for caching, or memcache, or other interesting PHP extensions that Apple does not provide you are in for a lot of pain and wasted time and effort. With MAMP it's simple. Also, with MAMP you have ownership of the conf files, so editing settings for PHP or Apache is quick and simple without a stop for authentication every time. (Of course, you want to set up your environment securely if you are on the internet.) Just for comparison, it took me about a day, off and on, to write the instructions in this blog post. By comparison, MAMP took less than an hour. Your time is worth a lot. Also, note that MAMP is for a development environment, not a production server.

Hello, John,

Thanks for sharing this writeup, and on sharing your perspective on using the Apple's built-in PHP support vs MAMP.

I have been wondering about this for a while, particularly with regards to Drupal -- I'll now be referring all questions to this post :)

Heck, if John VanDyk says it, it *must* be true!



This is a great blog piece. I am very happy about finding it. I'm hosting a web site on a Mac Mini and I don't want to use MAMP for production. I have everything working except for GD so I'm still looking. You've solved my MySQL startup problem which I appreciate greatly.

Great work! I'll post what I can find regarding GD.

You need to initiate your MySQL Start daemon:

Load the MySQL launchd configuration file:
sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld.plist

Great tutorial, John. Your wording helped me a lot but I am still hung up on something that must be missing. I'm using Leopard. There was no "Sites" in my user directory (I think I deleted it long before ago). So I copied the one from the "Guest" user. There were also no files at all in the /private/etc/apache2 directory so I copied yours into it changing the John to my user name (david). I then ran the configtest and got the following error message: "David-Crellens-Computer:/ david$ sudo apachectl configtest
Syntax error on line 2 of /private/etc/apache2/users/david.conf:
Invalid command '\xca', perhaps misspelled or defined by a module not included in the server configuration".

I removed all content of the file and saved it as a blank file. configtest passed the test and server worked as before I started this. I then put just a commented line in the file and saved it. configtest failed with same error msg as above. I tried searching on the '\xca' command and got no results. Any ideas?

I'm leery about implementing MAMP because I've already updated PHP from MAMP's version and I already have an up and running MySQL that I'd hate to replace.

In search of solving Web Serving problems with Leopard I learned that Leopard installs Apache2 in place of Apache1. Apache2 does some things slightly different but also in searching I found a shell script that is the cat's meow. It sets up virtual hosts for you in almost the Mac way, i.e., little hastle. Here is the info:
Go to Patrick Gibson's website: p and download the script:
Use it in terminal like this:
sudo /users/david/-sites/ crellen

It takes care of everything. Basically, after taking care of the httpd.conf prerequisites, it sets up a new file for each new host in /private/etc/apache2/virtualhosts/ and even creates the host directory if you didn't do that yet.

Run the script and you’re done. It rocks.

this is really very helpful tutorial indeed. At the same time I got a problem after initial installation of MySQL everything was just fine until I wanted to call from command line mysql. It did not start. Neither mysql_secure_installation. What I found is that neither of this appeared in /usr/bin directory. SO, if type ./bin/mysql it works just fine. What I suppose to do make this thing working? Thanks.

This was a great tutorial. Definitely a cut above the standard . I was up and running with Drupal in about an hour. I look forward to your new book!

Thanks for your research, I'll probably stick MAMP too.

Thanks, this is clear and helped me a lot.


Thanks so much for your tutorial, it's helped me get so far.
But I'm having one final problem with the last step "Run the Drupal installer by going to http://dev/drupal".

I keep getting a 404 Error when I go to that address, even though I've followed all the other instructions (http://dev/ comes up as the apache webpage, drupal installed in root).


Hi Jhon am installing drupal in Apple mac mini. but i dono the procedure. plz help me. i dono the database configuration. can u tel me details...

Jhon, awesome tutorial - simple and to the point. Works for me like a charm on Mac OS X 10.5.x.

From the different field. Has anyone succeeded in installing Xdebug in this environment for use with Net Beans?

Wonderful tutorial. Just happened to stumble upon it. I followed the instructions step-by-step and it worked great. Just wanted to let you know that right before the wonderfully named "Rejoicing" section, in the "Installing Drupal" section, the full file name and location whose write permissions need changing is (at least on my version of Drupal, 6.9): drupal/sites/default/default.settings.php, as opposed to drupal/sites/default/settings.php.

Just something minor I noticed and thought you might want to update.


You are supposed to copy default.settings.php to settings.php.

Otherwise I cannot get Drupal to install on a Mac at all. When I run the install.php it offers me the first screen, I ask it to install in English then I get a blank screen. Tracing through the code it is clear that it can't access the database it hasn't installed! Still can't figure out what permissions are wrong.

It would be so much simpler if Drupal came with a default database for the basic system that could be installed through phpMyAdmin or somesuch.


I'm always getting this Error:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Is it because I'm using XAMPP, or why do i get this error?

Still seeking a good solution for the lack of GD support in Leopard. All the tutorials I've found have follow up threads full of tangled caveats and corrections. Has anyone cracked this nut yet?