403 errors

started at 12 Oct 2007 by bradrice
  • bradrice
    12 Oct 2007

    I decided to upgrade my Apache. I followed the steps, but now I am getting Forbidden 403 errors on my webserver. I am just using localhost, as it is only my internal testing server. Any ideas why? I looked at my old config file and I can't see anything different that would suddenly cause that.

  • bradrice
    12 Oct 2007

    I did some testing and it is my virtual hosts that is messing things up. If I comment that out then everything works. Is there a way to virtual hosts to work for a localhost machine? I tried *, *:80, localhost:80, 127.0.0.1:80 and nothing seems to work. It worked for some reason before I upgraded.

    Here is a sample container

    NameVirtualHost 127.0.0.1

    <VirtualHost 127.0.0.1>
    DocumentRoot "/Library/Webserver/Documents/uakron"
    ServerName local.uakron.dev
    </VirtualHost>

  • Richard
    13 Oct 2007

    Did you put the domain name and the ip address in your host file ?

    If your Apache daemon is running as user www, does that user have read access to the directory ?

  • shunluoi
    22 Apr 2008

    I think I am having the same issue. i finally managed to get Apache 2.2.8 installed on Leopard and can access the default page at http://localhost. But I added a site in the httpd-vhosts.conf file and /etc/hosts file, but when i browse to it I get a 403 forbidden error.

    In my httpd.conf file i have the following settings:

    1. Apache runs as:
    User _www
    Group _www

    2. ServerName is set as:
    ServerName localhost

    3. DocumentRoot is set as:
    DocumentRoot "/Library/Webserver/Documents"

    4. Listen is set as:
    Listen 80

    In my httpd-vhosts.conf file I have:
    <VirtualHost *:80>
    DocumentRoot "/User/myusername/www/site1.dev/public_html"
    ServerName site1.dev
    </VirtualHost>

    The permissions for my /Library/WebServer/Documents folder is:
    drwxrwxr-x 40 root admin 1360 Apr 22 10:14 Documents

    The permissions for my /User/myusername/www/site1.dev/public_html folder is:

    drwxrwxr-x 3 myusername staff 102 Apr 22 11:03 public_html

    So I am thinking it has to do with the Apache running as user _www and not having permission to access the page. How do I give Apache (_www) permission to access my site1.dev site as well as any future virtual hosts that I set up?

  • Nick
    22 Apr 2008

    Hi,

    Try changing:

    3. DocumentRoot is set as:
    DocumentRoot "/Library/Webserver/Documents"

    to

    3. DocumentRoot is set as:
    DocumentRoot "/User/myusername/www"

    Also, don't forget to change:

    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/Library/Webserver/Documents">

    to

    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/User/myusername/www">

    further down in the httpd.conf file.....

    For virtual hosts I tend to use:

    <VirtualHost *:80>
    DocumentRoot /User/myusername/www/site1.dev/public_htm
    ServerName site1.dev
    ServerAlias http://www.site1.dev
    ServerAdmin webmaster@site1.dev
    </virtualhost>

    i.e. no quotes.

    Nick

  • Richard
    22 Apr 2008

    Hi, you don't need to change everything, just add the Virtual Host stuff. The best directory to put your sites in your user directory is in the Sites directory it has most properties set correctly. If you want a directory to be world readable use the following command

    chmod a+rx directory

    To make files world readable:

    chmod a+r filename

    or use wildcards

  • shunluoi
    24 Apr 2008

    So I removed the quotes from the DocumentRoot line in the httpd-vhosts.conf file.

    I also went to /User/myusername/www/site1.dev folder and changed the permissions for the directories "site1.dev" and "public_html" (under sitel.dev)

    I also changed the permissions for the index.html file in public_html.

    Do I understand correctly that I don't actually have to change the DocumentRoot line in httpd.conf?

    After doing all this I still get the 403 error. I then tried to move my files to the Sites directory in my user directory, and updated the httpd-vhosts.conf. But I still get the permission denied error.

    ...

    Okay, i now tried changing the DocumentRoot path in httpd.conf, and it works. Well, it works to go to site.dev. But now if I try to go to http://localhost, I get the 403 error.

    Does this mean websites can only be served from one directory path specified by DocumentRoot? Or is this where wildcards come in?

    Can anyone point me to some tutorials on how to use the wildcards?

  • Richard
    24 Apr 2008

    What is the error you get in your Apache logfile, that usually gives some more information.

    By the way, did you uncomment the include statement in your httpd.conf for the httpd-vhosts.conf file ?

  • shunluoi
    24 Apr 2008

    Currently I have in my httpd.conf file the following settings:

    DocumentRoot "/Users/myusername/WebDev/sites"
    <Directory "/Users/myusername/WebDev/sites"></Directory>

    I did uncomment the include statement in httpd.conf for the httpd-vhosts.conf file.

    In httpd-vhosts.conf I have the following vhost definitions:

    <VirtualHost *:80>
    DocumentRoot /Library/Webserver/Documents
    ServerName localhost
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /Users/myusername/WebDev/sites/site1.dev/public_html
    ServerName site1.dev
    ServerAlias http://www.site1.dev
    </VirtualHost>

    I can browse to http://site1.dev and it displays the pages. But if I browse to http://localhost/ I get a 403 error and in my apache logfile I get the following error:

    [error] [client 127.0.0.1] client denied by server configuration: /Library/Webserver/Documents/

    What is frustrating to me is that I have done this in the past and have been able to serve different sites just fine...but I don't remember what i did differently.

    If you want to see my httpd.conf and httpd-vhosts.conf files I can send them to you to look at.

    Thanks

  • Richard
    24 Apr 2008

    Could you send them to me and I'll have a look...

  • shunluoi
    25 Apr 2008

    I figured out what the issue is. I need to add the following code in the httpd-vhosts.conf file to give permission to access the site(s) I put in the specified folder:

    <Directory /Users/myusername/WebDev>
    Order Deny,Allow
    Allow from all
    </Directory>

    I then put my site1.dev folder (i did away with the 'sites' folder) and any additional site folders in WebDev and the webpages there can be accessed.

Reply

You must log in to post.