Search

How To setup correct Web servers and file permissions in Linux

How To setup correct Web servers and file permissions in Linux

How To setup correct Web servers and file permissions in Linux

Web server file permissions are the most important. If not set up properly, your web server is not able to create / write files and you will get an error, in which case we need to setup the proper web server permissions.

The following setup helps you get the right web server.

To add Web server user which you like.

useradd webmasters

To add Web server Group which you like

 groupadd webmasters

To set Special permission

 setfacl -R -m g:webmasters:rwX /var/www/html

To set Special permission run two times

setfacl -R -m  d:g:webmasters:rwx /var/www/html

To change files ownership

chown -R webmasters:webmasters /var/www/html

To change files permission

chmod -R 755 /var/wwww/html

To change php session files permission

ls -ld /var/lib/php/session/
chown :webmasters /var/lib/php/session/
ls -ld /var/lib/php/session/

Conclusion

In this tutorial, it helps to improve the security of the web server.

Sys Admin

Sys Admin

I am a Red Hat Certified Engineer (RHCE) and working as an IT Professional since 2012...