Blog / Fixing Apache on Mountain Lion

It’s Mac OS X upgrade time again, which means a lot of stuff will be mysteriously broken. My first casualties were the websites I hosted locally.

Happily, it’s not hard to fix. Mountain Lion doesn’t have a “Web Sharing” button anymore (boo), but all it did is mangle your Apache configuration file (…yay?).

This is mostly a copy-paste from my previous guide.

How to fix Apache, MySQL and PHP

Edit the Apache configuration file. You’ll have to type your password to edit this file.

$ sudo nano /etc/apache2/httpd.conf

Use Ctrl-W and type libphp5 to find this line (below). Uncomment it by removing the pound sign (#) in front.

#LoadModule php5_module libexec/apache2/

Enable virtual hosts by using Ctrl-W to search for httpd-vhosts.conf and uncomment the line below.

#Include /private/etc/apache2/extra/httpd-vhosts.conf

Set the Apache process to run as your username so it has access to your files. This is kind of unsafe, but as long as you’re the only one working on your computer it should be fine.

Use Ctrl-W to search for _www and replace User with your username (AKA the one word name of your home folder) and Group with “staff”.

User JordanRoher
Group staff

While Passenger itself seems to be intact, you’ll need to put its lines back at the bottom of your Apache config file. Your numbers may look different than mine.

LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-3.0.11/ext/apache2/
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-3.0.11
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Press Ctrl-X to exit, type Y to save the buffer, and press enter to keep the name of the file.

Finally, restart Apache. If you don’t see an error, it worked.

$ sudo apachectl restart