Question

I have tried every option to get apache2 to work in Mountain Lion, and I am baffled by how impossible the task seems to be.

I just got a new iMac and on a fresh, clean install, I went about setting up apache to serve local sites.

Using the usual suspects of possible configuration changes, I can get apache to actually "start" but then things go downhill from there.

No matter how I define the local server root, I always get a Forbidden error. I can chmod the directory structure to 777 and I still get a Forbidden error.

I have set the server root as the default /Library/WebServer/Documents/, set it to /Users/myUserName/Sites/, /Users/myUserName/Documents/Sites, /Volumes/ExternalDrive/Site/ and any other possible combination, modifying /etc/apache2/httpd.conf and/or /private/etc/apache2/httpd.conf as well as the vhosts file and the myUserName.conf file. Nothing makes a difference.

I have restarted apache with sudo apachectl restart as well as sudo apachectl stop followed by sudo apachectl start.

Nothing works.

Can someone help me get this issue resolved? I am beginning to want to throw my brand new iMac against the wall.

Note, I am not a novice at this and I have set up dozens of Macs. However, nothing seems to work this time. I even reformatted and reinstalled the system again.

Was it helpful?

Solution

Run this command to see if you have errors in your configuration: sudo apachectl -t

You can find more info here.

OTHER TIPS

sudo apachectl start starts Apache and enables /System/Library/LaunchDaemons/org.apache.httpd.plist.

To make http://localhost/~username/ work, save something like this as /etc/apache2/users/username.conf:

<Directory "/Users/username/Sites/">
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

I didn't have to edit any other files or httpd.conf.

If you're really struggling, you might give VirtualHostX a try… it's a Mac app that helps you configure apache to run multiple websites from a single Mac, but it works just as well with a single website. It's a paid app, but it has a 30-day trial period.

Try MAMP or even MAMP Pro, both have software that you can start/stop your apache and mysql.

http://www.mamp.info/en/index.html

MAMP Pro also supports virtual hosts

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top