Updating to Apache2 for Mac OS X Tiger (Apache 1.3)
This past weekend, I wanted to update the built-in Apache 1.3 (Darwin) build with a more recent Apache 2.2.4, all while preserving the Mac OS X’s Personal Web Sharing capabilities transparently. Here are the simple steps:
- Download the latest apache src from http://www.apache.org. In my case it was version 2.2.4
- Extract the src to a directory where you keep all your src files, cd to that directory
./configure –prefix=/usr/local/apache2 –enable-so –enable-mods-shared=most
make
make install
- Replace /usr/local/apache2 with the directory you’d like apache to be installed in. I named mine apache2. The above command will build apache2.
cd /usr/sbin
sudo mv httpd httpd.apache1.back
sudo ln –s /usr/local/apache/bin/httpd httpd
sudo mv apxs apxs.apache1.back
sudo ln –s /usr/local/apache/bin/apxs apxs
sudo mv apachectl apachectl.apache1.back
sudo ln –s /usr/local/apache/bin/apachectl apachectl
- httpd (the binary for apache) version 1.3 is installed in /usr/sbin/. You can see the version by typing “httpd -v” in the command line. Replace this (after backing it up) with a symlink to our new apache2 httpd binary. This should also be done for apachectl and apxs.
- At this point. apache2 is already running on your system, but the conf files are not quite ready. Add the following to your httpd.conf (found under /usr/local/apache2/conf). The PidFile is where the Personal Web Sharing manager looks to see if an apache instance is running.
PidFile "/private/var/run/httpd.pid"
- You should also add the following to enable user directories.
<IfModule mod_userdir.c>
UserDir Sites
</IfModule>
Include /private/etc/httpd/users/*.conf
- At this point, you are all set. Try toggling the Personal Web Sharing on and off. The next steps you might want to take (optionally) is to add MultiView support and change your DocumentRoot. These can all be done in the httpd.conf file. You might also want to uncomment the line that includes support for http://localhost/manual/
- You can also find the previous 1.3 conf file at /private/etc/httpd. Notice how much more verbose this conf file is compared to the apache2 conf file. This is because most of the additional conf settings can be includes via conf/extra directory.
November 22nd, 2007 at 7:09 pm
[…] A while ago, I posted a blog entry about upgrading to apache 2.x on OS X 10.4. I just got around to installing the brand-spanking new version of Apple’s OS (Leopard, OS X 10.5) and realized that it comes with apache 2.2.6! […]