I am developing web applications with Ubuntu Linux, MySQL and PHP.

I put my files in the /var/www/some_web_project/ directory. I have problems with permissions, for example when I want to output image in my web application by <img src="images/some.jpg"/>, it does not show me images until I change permissions of the folder. Usually I change it to 777. But I do not think this is the right from a security perspective

What should the correct permission mode be?

  • What is the owner/group of some_web_project? – mako_reactor Feb 13 '13 at 15:07
  • Using root for the owner is fine; especially if you login with an unprivileged user who is a member of the group that has write permissions to the directory/files. – Chris S Feb 13 '13 at 15:53

Directory Permissions should either be 775 or 755, depending on whether you use groups or not (respectively). Be sure to set the owner and group appropriately (it should not be owned by the www user or anything related to the webserver daemon itself).

File Permissions should be 664 or 644, depending on group use again. CGI scripts should have the same permissions as the directories however.

chmod -R ug=rwX,o=rX /var/www/some_web_project or chmod -R u=rwX,go=rX /var/www/some_web_project should set permissions correctly, except for CGI Scripts and their like, which will need manual attention.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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