Enable Apache on Mountain Lion

Mac OS X Mountain Lion comes with Apache installed but not enabled. Here are the steps to re-enable Apache

1. Open the OS X Terminal (/Applications/Utilities/)

2. Create and open an Apache user configuration file named for your account in your favorite editor. I am using TextMate so I used the following command

sudo mate /etc/apache2/users/[username].conf

3. Copy the following text into the file that opens, but be sure to change the [username] text to the short name of your user account:

<Directory “/Users/[username]/Sites/”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

4. Save the file and close the editor.

5. Enable apache by typing

sudo apachectl start

6. Verify Apache is up by typing the following url into your browse

http://localhost/~%5Busername%5D

7. To enable the server even after subsequent reboots

sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool false

8. To disable the server even after subsequent reboots

sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool true

9. To be sure the files (and any others you may have configured) are properly accessible

sudo chown root:wheel /etc/apache2/users/*
sudo chmod 644 /etc/apache2/users/*
sudo apachectl restart

Dwain