MacOS – OS X Lion – How to configure website on Apache

apachemacos

I'm on my first steps with OS X and I'm trying to setup Apache so I can develop a website. I configured a new alias on /etc/apache2/other with the following content, pointing to my project folder, like this:

Alias /mySite /Users/me/Documents/workspace/mySite   
<Directory /Users/me/Documents/workspace/mySite>
  Options Indexes     
  Order allow,deny
  Allow from all 
</Directory>

However, accessing to localhost/mySite gives me a 403 forbidden. I have access to localhost (which I realize has its web folder at /Library/WebServer/Documents) and I have access to localhost/~me (which shows the content of ~/Sites). I also tried to deploy my site in that folders and I can have access to it, but my ideia was, at most (if configuring the site on Apache fails), to use a symbolic link there pointing to the real project location, but right now I'm also getting the same 403 with it. Can someone help me with this?

Thanks!

Best Answer

The default permissions on ~/Documents don't allow anyone but the owner access to it. Apache accesses the documents as the _www user, so if that user can't get to the web folder, you'll get a permissions error.

If this is the problem, there are a couple of possible solutions: you can either move the project folder outside of ~/Documents (e.g. /Users/me/workspace/mySite), or change the permissions on ~/Documents to allow Apache in (chmod +a "user:_www allow search" ~/Documents should do the trick).