I actually ran into this same problem (at least the same symptoms) just today. In my case, I looked at /var/log/apache2/error_log
and saw a bunch of errors like this:
[Mon Mar 19 15:30:30 2012] [error] [client ::1] Directory index forbidden by Options directive: /var/empty/
Then I looked in /etc/apache2/httpd.conf
and saw these two lines…
<IfDefine MACOSXSERVER>
DocumentRoot /var/empty
…and then later, these lines…
<IfDefine !MACOSXSERVER>
<IfDefine WEBSHARING_ON>
# Some comments were here
DocumentRoot "/Library/WebServer/Documents"
…so I figured that somehow MACOSXSERVER
was getting defined, when it shouldn't be, since this machine is not a server machine. Then I remembered that I needed to install the Lion Server Admin tools on this machine, and the way Apple's documentation told me to do that was to install the Lion Server package from the Mac App Store on my admin machine, even though this wasn't intended to be a server machine. So maybe that actually/accidentally transmogrified my admin machine into a Mac OS X Server machine. To double-check, I ran:
$ sw_vers
ProductName: Mac OS X Server
ProductVersion: 10.7.3
BuildVersion: 11D50
Sure enough, my machine was now reporting itself as Mac OS X Server, even though all I had wanted to do was put the Server Admin Tools on this machine.
Back to the Apache problem, I eventually found /etc/apache2/ReadMe.txt
, which explained about those Mac OS X-specific Apache defines (be sure to read it yourself for more good info!), and then it said this:
Those IfDefine settings – MACOSXSERVER, WEBSHARING_ON, WEBSERVICE_ON – are set or not set by Apache's launchd plist, which is present in
/System/Library/LaunchDaemons/org.apache.httpd.plist.
So in my case, I chose to fix it by editing in that launchd
plist
for Apache to not defined MACOSXSERVER
, since I don't really consider my machine a server, and I want to control this stuff from the Web Sharing checkbox in the Sharing panel of System Preferences, not from Server.app.
So, I edited this file:
/System/Library/LaunchDaemons/org.apache.httpd.plist
To remove or comment out these lines, in the ProgramArguments
array:
<string>-D</string>
<string>MACOSXSERVER</string>
I chose to comment them out by putting SGML comment start/end markers before and after them like this:
<!--
<string>-D</string>
<string>MACOSXSERVER</string>
-->
After saving my changes to that plist
file, I restarted Apache gracefully:
sudo apachectl graceful
…and it was all better!
I may have had to reload the page in my browser a time or two if my browser had cached a "403 Forbidden" result for the page I was trying to get to.
Even if this isn't the exact same root cause of your problem, I hope my saga helps you figure out your situation.
Best Answer
In case anyone has the same problem, this is the solution:
more info: http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/ (see comments below)