Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I think my Apache must be all screwed up. I don't know if it ever worked. I just upgraded to Snow Leopard, and the first step on this tutorial is to start apache and check that it's working by opening http://localhost. It starts fine but when I go to localhost I get a 403 forbidden error.

I don't know where to start figuring out how to fix it, so I wonder if a fresh install of Apache would do the trick.

What do you think?

Update: I found some error logs in /private/var/log/apache2/. Found this in one of the logs. Not sure what it means:

[Tue Nov 10 17:53:08 2009] [notice] caught SIGTERM, shutting down
[Tue Nov 10 21:49:17 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist
Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist
httpd: Could not reliably determine the server's fully qualified domain name, using Andrews-Mac-Pro.local for ServerName
mod_bonjour: Skipping user 'andrew' - cannot read index file '/Users/andrew/Sites/index.html'.
[Tue Nov 10 21:49:19 2009] [notice] Digest: generating secret for digest authentication ...
[Tue Nov 10 21:49:19 2009] [notice] Digest: done
[Tue Nov 10 21:49:19 2009] [notice] Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k DAV/2 PHP/5.3.0 configured -- resuming normal operations

Update: I also found something in the dummy-host.example.com-error_log file. I didn't set these dummy-host things by the way. Is this the default configuration?

[Tue Nov 10 21:59:57 2009] [error] [client ::1] client denied by server configuration: /usr/docs

Update: Woohoo! I found the file that had the virtual host definitions. It was in /etc/apache2/extra/httpd-vhosts.conf. It had those two dummy virtual host settings in there. I added a localhost virtual host. Not sure if this is necessary, but since it wasn't working before, decided to do it anyway. After removing the old virtual hosts, adding my new localhost virtual host, and restarting apache, it seems to work. So I guess whenever I want to add a virtual host, I only need to add them to this file? Or is there a hosts file somewhere, like there is on Linux?

Update: Yes, there is an /etc/hosts file that need to be changed to. Add the virtual host name to that file.

share|improve this question
    
So wait, you've solved it? –  random Nov 11 '09 at 7:56
    
Yes, I think I did –  Andrew Nov 11 '09 at 16:59
    
There is a more updated answer here: superuser.com/questions/200223/… –  Doug Oct 16 '10 at 23:34
    
please accept your own answer? This question just got bumped by community to give it some attention, but it seems it doesn't need it? –  Arjan Dec 4 '10 at 13:01
add comment

2 Answers

up vote 2 down vote accepted

If you're getting a 403 error it probably means the directory does not exist, or the privileges on that directory won't let you see it.

My problem was that the default virtual host settings were pointing to a directory that didn't exist.

So here's what you should do: (assuming you're on Snow Leopard)

  1. Find and open your virtual hosts configuration file.

    pico /etc/apache2/extra/httpd-vhosts.conf
    
  2. Check that your virtual host definitions are in there, otherwise create them

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/Users/yourusername/Sites/mysite"
    ServerName mysite.local
    ErrorLog "/private/var/log/apache2/mysite-error_log"
    CustomLog "/private/var/log/apache2/mysite-access_log" common
    </VirtualHost>
    
  3. Open up /etc/hosts file and add your virtual host name. This is what's in mine:

    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1          localhost
    255.255.255.255    broadcasthost
    ::1                localhost 
    fe80::1%lo0        localhost
    
    
    # VIRTUAL HOST START
    127.0.0.1          localhost
    127.0.0.1          mysite.local
    # VIRTUAL HOST STOP
    
  4. Now restart Apache and you should be good to go!

    sudo apachectl restart
    
share|improve this answer
    
Where do I input that command to restart apache? –  Doug Oct 16 '10 at 22:52
    
in a terminal window –  Andrew Dec 6 '10 at 15:45
add comment

Also it is labeled as a warning, it is really the critical line in your error log:

Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist

Apache is searching for a directory that will hold the files that will be solved when you talk to it. Apparently, this directory doesn't exist and thus Apache is not able to solve you anything. Create the directory and place some index.html file in there or edit your config file to point Apache to another directory.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.