Apache file permission

Posted under » Ubuntu » Apache » LAMP Security updated on 4 Mar 2021

If you get a file permission error while using Apache, it is most probably because www-data is not able to access the file. The file owner is probably you, "webmasta" for example but "www-data" need to access to it too. If redhat, instead of "www-data", it is "apache". You can see determine by "cat /etc/group". Read more on this.

As root

usermod -G www-data -a 'webmasta'
chown webmasta /var/www -R
chgrp www-data /var/www -R

If you encounter "access denied because search permissions are missing", then you have to make it a bit loose... not too much but just adequate such that even "others" is able to read.

chmod 774 /var/www -R

Please take note that you after a while, when you create a folder on the www root folder under webmasta and it will cause a "no priviledge" error. You have to make sure www-data is able to read it by doing this again.

chgrp www-data /var/www -R

 

web security linux ubuntu GIT svn Raspberry apache mysql php drupal cake symfony javascript Ajax css