Apache setup on Mac OS X Lion

Posted by: scoopseven 12 years, 1 month ago

I always feel the need to write some silly commentary to explain why I'm documenting procedure in a public way to help anyone else who shares similar circumstances. Enough for today.

Enable System Preferences->Sharing->Web Sharing. After this web pages in DocumentRoot specified in httpd.conf, will be served by Apache.  And even though Apache is started at this point, you don't really have control over the service.  Running:

sudo apachectl stop

won't produce any errors, but it won't restart httpd either. System Preferences has some strange control over the apache service at this point.  You can still stop/start it via the System Preferences pane, just not the command line.  In order to correct this, you need to run this command:

sudo apachectl graceful

This should stop httpd and at this point you'll be able to stop/start/restart it via the command line.  You can always check if the service is running like this:

ps aux | grep http

and you can always check your config files with:

sudo apachectl configtest

I stumbled upon this because when I originally started Apache via the "Web Sharing" preference pane and tried to access http://localhost I got this error in my browser:

You don't have permission to access / on this server.
Apache/2.2.19 (Unix) DAV/2 Server at localhost Port 80

The apache log error read:

[error] [client ::1] client denied by server configuration: /path/to/http/docs/

Turns out the changes I was making to httpd.conf weren't being seen because restarting the service via apachectl was having no effect, so my configuration changes on things like Directory blocks and DocumentRoot paths just weren't being picked up.

Currently unrated

Recent Tweets

Recent Posts






RSS / Atom