Who knew Apple changed so many settings with the Apache 2 install on Mac OS X Snow Leopard? According to this page it is pretty much scattered everywhere on the system according to “Apple logic”. I decided that I want to update to the latest Apache (2.2.17 as of this writing) and while preserving some of Apple’s paths, also consolidate some so Apache related files can be relatively easy to find.
To start, download and extract the latest Apache
source. You should find a folder called “httpd-version”, in my case it’s called “httpd-2.2.17″ because that’s the version I downloaded.
If you want to keep the Mac OS X desktop layout, just use:
CFLAGS=”-arch x86_64″
./configure -enable-layout=”Darwin”
-enable-mods-shared=all
-with-ssl=/usr
-with-mpm=prefork
-disable-unique-id
-enable-ssl
-enable-dav
-enable-cache
-enable-proxy
-enable-logio
-enable-deflate
-with-included-apr
-enable-cgi
-enable-cgid
-enable-suexec
Darwin already exists as a default in the Apache layout. But then your httpd.conf will end up being in “/etc/apache2/”
I went out of my way to make it a little bit different. Of course you don’t have to do any of these things below if you just want to stick to Mac OS X defaults.
Remove the remnants of the Apache 2.2.15 install from Snow Leopard according to the distros default layout page I linked earlier, but that’s not necessary. I did it so I don’t get confused where configuration files are located and I wanted to minimize as many copycats as possible. If you follow my guide step-by-step, and want the same setup as me, just delete the following folders:
/etc/apache2/
/var/log/apache2/
Not too bad right? Only 2 folders to remove.
Now we need to change a few lines in the layout configuration file that came with your Apache source.
Inside the “httpd-2.2.17″ folder you just extracted you will find a file named “config.layout”, open this with a text editor, TextEdit would work. I’ve been using TextWrangler, makes no real difference.
Find this line: <Layout Mac OS X Server>, change the prefix path to “/Library/WebServer”. Do the same to “config.layout” file in “srclib/apr” and “srclib/apr-util”. Then run these commands in Terminal.
CFLAGS=”-arch x86_64″
./configure -enable-layout=”Mac OS X Server”
-enable-mods-shared=all
-with-ssl=/usr
-with-mpm=prefork
-disable-unique-id
-enable-ssl
-enable-dav
-enable-cache
-enable-proxy
-enable-logio
-enable-deflate
-with-included-apr
-enable-cgi
-enable-cgid
-enable-suexec
Once the configuration is finished, run “make”, then “sudo make install”.
Go into your system preferences and restart Web Sharing and then check your Apache version with “httpd -v”. You can also visit http://localhost/ to see “It works!”
Enjoy! All related Apache files that you need to modify, such as httpd.conf is now located in /Library/WebServer/. I just think it’s so much easier to find httpd.conf in a pinch this way.
Update: use directions from DIY Mac Server instead, they adhere to using /usr/local/ and I believe it’s a better setup.