Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I deleted Library/WebServer/Documents folder and created it again.

When I visited localhost it gave me forbidden error.

I ran sudo chown _www:_www Documents

And forbidden error was gone, but now I couldn't edit files at all. I couldn't even go into Documents folder from GUI.

Any ideas what is correct way to set this up??

ty.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

There's no single "correct" way to set this up; what the permissions need to be depends on who should be allowed to do what to which files. Does anyone other than you need to be able to edit the web files? Is it ok if other users on the computer can read the web files (directly, as opposed to via the webserver)?

Here's a simple option that gives you full (read+write) access, lets the webserver read the files, and locks everyone else out of the web folder (note: replace "sandro" with your actual username):

sudo chown -R sandro:_www /Library/WebServer/Documents
chmod -R u=rwX,g=rX,o= /Library/WebServer/Documents

If you need other access rules for the web files, please clarify.

share|improve this answer
    
I also tried sudo chown -R sandro:_www /Library/WebServer/Documents, in this situation I get forbidden error when visiting localhost. –  Sandro Dzneladze Nov 21 '12 at 9:32
    
Did you also do the chmod command? If you're still having trouble after that, post the results of ls -lea /Library/WebServer/Documents so we can see what's going on. –  Gordon Davisson Nov 21 '12 at 15:18
    
Yes it was chmod problem. Eventually I just did permission check on disk and it fixed it for me. And yes your solution was correct, thanks! –  Sandro Dzneladze Nov 21 '12 at 23:52
add comment

Try sudo chmod 755 foldername, that allows all to Read & Execute in that directory. That is the default on my web-server for public sites.

Edit: My original post was 777 assuming that this is a local machine for solely local development to avoid issues. However, for anything open, public, sensitive, etc - it should not be.

share|improve this answer
    
chmod 777 is almost always the wrong answer -- it's a bit like having a little trouble with one of your door locks, and "solving" the problem by leaving the door wide open all of the time. –  Gordon Davisson Nov 21 '12 at 2:26
    
Generally I would agree, but for presumably local web development, not really a huge issue. –  nerdwaller Nov 21 '12 at 2:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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