Apache2 userdir enabled, but still have no access

The public_html directories need to have their permissions like this so that the user that Apache is running as can access it:

$ chmod -R 755 ~/public_html

still not work?

If you look in your Apache error logs you might see a line like this:

[Fri Aug 02 21:06:59 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /~kaiyin denied

This is telling you that Apache doesn't have permissions to navigate to your user's directory (~kaiyin) in this example.

How to fix this?

You need to make sure that read + execute bits are set for either a group that Apache is a member of or the others read + execute bits are set on the user's directory as well so that Apache can access the public_html folder down below.

Example

/home
|-- [drwxr-x---]  /home/sam

/home/sam
|-- [drwxr-xr-x]  /home/sam/public_html

References

  • How can I make a public HTML folder in Ubuntu?