I set up Web Sharing in System Preferences on Mac OS X 10.6 and clicked the link it gave me there. Unfortuantely, Apache gave me this 403 error:

Forbidden

You don't have permission to access /~myusername/index.html on this server.

Access log displays: 10.0.1.2 - - [30/Jun/2010:16:25:15 -0700] "GET /~myusername/ HTTP/1.1" 403 210

Error log displays: [Wed Jun 30 16:26:09 2010] [error] [client 10.0.1.2] client denied by server configuration: /Users/myusername/Sites/

Curiously enough, accessing http://localhost works fine. It's just with two of the user folders that I've having trouble with, the other user folder, which is newer than my system upgrade, is working fine.

I've had this working on my machine in Leopard before, so I chmodded everything in ~/Sites to 755, which didn't do any good. Any suggestions? I presume I've done something to my machine that's caused this, since I can't imagine Apple messing up on something like this.

I did set up PEAR with these instructions, but I have no idea if that could be the cause of it.

link|improve this question

60% accept rate
Sorry if this is a dumb question, but exactly what URL are you going to? I ask because the URL "/~myusername/index.html" is an odd one -- it should either be "~myusername/index.html", or it should be "localhost/~myusername/index.html";, or something similar. Simply starting from / and then adding ~myusername smells funny. In addition to (or instead of) answering that, you can go into Console.app (/Applications/Utilities/Console.app) and find the apache2 access_log and error_log. Pull that up, perhaps clear the display, and then re-try your URL to see what the error log tells you. – khedron Jun 30 '10 at 23:19
@khedron: The URL is localhost/~myusername/index.html, but the error displays the /~myusername/index.html part – waiwai933 Jun 30 '10 at 23:26
OK, just checking. What does the apache log say in the console (console.app)? – khedron Jul 1 '10 at 1:04
@khedron: I posted the access and error log up in the question. Is there another one? – waiwai933 Jul 1 '10 at 1:09
Sorry, I didn't see that. OK -- that clearly shows the URL is understood correctly, but is denied. In that case.. hmm, can't format this properly in a comment, see answer down below. – khedron Jul 1 '10 at 2:36
feedback

7 Answers

For Apache to see the file, the user that Apache runs as (probably www or _www) must have access to these users' Sites directories. Having read/execute access to the contents of ~/Sites is not enough, because it has to be allowed to traverse from / down the path to ~/Sites. So make sure /, /Users/, /Users/myusername/, and /Users/myusername/Sites/ all have at least "a+x" permission (the eXecute bit on directories allows that user class to traverse the directory, even if Read access is not allowed).

ls -lde / /Users/ /Users/myusername/ /Users/myusername/Sites

If any of those directories doesn't show the last "x" set (the one for "others"), then use something like chmod a+x ... to set it for that directory.

If the ACL for any of those directories shows that user www has been specifically denied access, then use the appropriate arguments to chmod to fix the ACLs.

link|improve this answer
The execute bit is set for all of those directories, but I don't know how to check if a specific user has been denied access. – waiwai933 Jul 1 '10 at 23:00
That's what the "e" in "ls -lde" is for. It lists the ACLs (if any) for each of the files. – Spiff Jul 1 '10 at 23:49
Changing permissions on /Users/myusername to chmod 755 fixed the issue for me. – Mark Robinson May 12 '11 at 14:24
feedback

Continuing conversation from initial question comments -- Check out your /etc/apache2/httpd.conf file. On my machine, I have this:

# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf

I suspect yours is commented out. I vaguely recall changing this by hand when moving from 10.5 to 10.6 and the default changed.

This is probably obvious, but you'll have to use sudo to edit the file because it will be owned by root.

link|improve this answer
Nope, mine looks exactly like yours. – waiwai933 Jul 1 '10 at 22:59
feedback

For reference, I just dealt with this, and none of the answers here worked in my specific case. I was configuring virtual hosts, but more importantly, I needed my htaccess files to actually work.

I changed on "AllowOverride None" to "AllowOverride All" in my /etc/apache2/users/USERNAME.conf file, and all of my sites started to be forbidden.

I changed it back and and then changed it only for one site in my httpd-vhosts.conf file, and only that site was forbidden.

After looking at the logs and seeing the problem was with url rewriting and the lack of FollowSymLinks, I went back to the USERNAME.conf file. I switch "AllowOverride None" to "AllowOverride All" and added "Options +FollowSymLinks" on the next line.

Things started working. I came from using xampp on windows and it had a lot of these settings already set server-wide for dummies like me.

link|improve this answer
thanks so much, spent quite some time figuring out what's going on, didn't have to tinkle with Apache / PHP for some time now – gryzzly Mar 6 at 23:59
feedback

You probably don't have Indexes turned on. If you don't you will need to either create an index file (index.html or index.php) or specify the file explicitly, i.e. http://localhost/~me/mypage.html.

link|improve this answer
Sorry, just to double check, I should be visiting localhost/~myusername/index.html and have a file called index.html in my Sites folder, right? If so, then the 403 is still happening. – waiwai933 Jul 1 '10 at 0:47
You shouldn't be visiting ~myusername at all I believe. http://localhost/ should point to /Users/youruser/Sites/. – Josh K Jul 1 '10 at 2:23
feedback

I had the same problem: My (old) account wasn't accessible, but another user's account which were created after upgrading to Lion worked just fine.

After making sure your /etc/apache2/users/USERNAME.conf looks like this:

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

do a sudo chown root:wheel /etc/apache2/users/USERNAME.conf

it appears that this permission setting isn't set during the OS upgrade, and the Apache user can't read the config file, and throws an error.

At least this solved it for me.

link|improve this answer
feedback

update for Lion in 10/2011 I had to also add

UserDir enabled so my /etc/apache2/extra/httpd-userdir.conf is like this :

UserDir enabled 
UserDir Sites

#
# Users might not be in /Users/*/Sites, so use user-specific config files.
#
Include /private/etc/apache2/users/*.conf

<IfModule bonjour_module>
   RegisterUserSite customized-users
</IfModule>
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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