Apache 2.2 on OS X Tiger

System Preferences
System Preferences

This guide will show you how to install Apache 2.2 on Mac OS X Tiger (and probably Leopard) in a way that will allow you to turn the apache server on and off via System Preferences. Phpmac.com had a guide to do this for Apache 1.3 but I have been unable to get onto that website for a long while now so I decided to write my own guide. This guide assumes that you are installing from source, that you have the Xcode package installed and you know how to user the Terminal.

Getting the source
First thing you will need to do is to go to httpd.apache.org and download the latest version of Apache 2.2. I used version 2.2.8 but the latest is 2.2.9 at the time of writing this. You should see a link to the source on the front page.

Configure and Compiling
I choose to install apache to /usr/local/apache2 with modules enabled. Assuming that you have unpacked the version of Apache you have just downloaded you should open the Terminal and change into that location.
$ ./configure --prefix=/usr/local/apache2 \
--enable-module=most \
--enable-shared=max
$ make
$ sudo make install

These commands will configure the httpd package, compile and then install it. This is the easy part, the hard part is configuring Apache to run from system preferences.

httpd.conf
Now that Apache is installed we need to configure it. There are three things you will need to do to the config file which is located in /usr/local/apache2/conf/httpd.conf . The location will depends upon what you used for –prefix= .

You need to search for the user and group name in httpd.conf. The default user and group is “daemon” but OS X uses “www”. This is line 65 on my install. After you have changes the user and group from “daemon” to “www” it should look like this.

User www
Group www

At the bottom of this config file you need to add a line to tell Apache where to store it’s PID file. This is important as this tells OS X what program to terminate when you stop the Apache service.
PidFile /var/run/httpd.pid

System link
This is the last step to getting Apache 2.2 to work from system preferences but I have an important note. This moves the default Apache 1.3 binary and replaces it with a link to our Apache 2.2 install. I have found that when I install one of Apple’s security updates the link has been replaces with the original Apache 1.3 binary. Therefore you may have to repeat this step from time to time.

In there terminal there are three command you have to run. The first one moves us into the directory that we need to work in. The second commands moves the Apache 1.3 binary out of the way and the final command replaces it with a link to our Apache 2.2 install.

$ cd /usr/sbin
$ sudo mv -v apachectl apachectl-1.3
$ sudo ln -sv ../local/apache2/bin/apachectl .

The End
Now all you have to do is go to System Preferences, click on “Sharing” and then enable “Personal Web Sharing”. When you open up your browser and type in 127.0.0.1 or [::1] (IPv4 and IPv6 respectively) you should see “It Works!“.

3 Replies to “Apache 2.2 on OS X Tiger”

  1. Thank you for this. It helped a lot. The other blogs I came up with are all a bit out of date, so I was glad to find this.

    It does appear that if you leave –prefix out, but enable Darwin template with:

    ./configure –enable-layout=Darwin

    then you don’t have any need to put a symlink in /usr/sbin. However, it does install apache2 in /etc/.

    I have a problem, though. How do I get my localhost/~user directory working again?

  2. Unfortunately, it didn’t do much for me. For some reason, enabling shared doesn’t work, because it doesn’t build .so files, so none of the shared modules can be loaded.

    I also get “Forbidden” errors as soon as I enable Named Virtual Hosts, but that’s probably a different issue entirely.

Leave a Reply