Apache permissions

apache

I'm trying to get LAMP working on OSx Lion and am having a little trouble.

Have Apache, MySQL, and PHP set up and working just fine. Have turned on "Website" under sharing in Settings. Removed the original ~/user_name/Sites folder and created a symbolic link of Sites to a directory withint ~/user_name.

Now when I try to run http://localhost/~user_name I get:

Forbidden You don't have permission to access /~user_name on this
server.

Where and how do I change these permissions?

Best Answer

When accessing websites on your "localhost", there are several permissions which are required. The localhost content may be in your Sites directory, in which case, these commands may help prevent any "Forbidden" messages.

Ensure the Users directory allows read directory access:

cd /
sudo chmod -v 755 Users

Ensure the username directory allows read directory access:

cd Users
sudo chmod -v 755 username

Ensure your Sites directory allows read directory access:

cd ~
chmod -v 755 Sites

Every subdirectory of Sites needs read access:

cd ~/Sites
find ~/Sites -type d -print -exec chmod 755 {} \;

Every file in Sites and subdirectories needs read access:

cd ~/Sites
fing ~/Sites -type f -print -exec chmod 644 {} \;

Apache uses the _www group so, to give Apache full access to everything in the Sites directory, set the extended attributes with this:

chmod -R +a "group:_www allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" ~/Sites