Linux website directory permissions settings

The setting of read and write permissions of Apache website directory under Linux

 

The setting of website directory file permissions is very important to the security of the website. The following briefly introduces the basic setting of website directory file permissions.

We assume that the user and user group running the http server is www, the website user is centos, and the website root directory is /home/centos/web.

Method/Step

  1. 1

    We first set the owner and all groups of the website directories and files to centos, www, the following command:

    chown -R centos:www /home/centos/web

     

  2. 2

    Set the website directory permissions to 750. 750 means that centos users have read, write and execute permissions on the directory, so that centos users can create files in any directory, and the user group has read and execute permissions, so that they can enter the directory. Other users have no permissions.

    find -type d -exec chmod 750 {} \;

     

  3. 3

    Set website file permissions to 640. 640 means that only centos users have the permission to change website files, the http server has only the permission to read files, and cannot change files, and other users have no permissions.

    find -not -type d -exec chmod 640 {} \;

     

  4. 4

    Set writable permissions for individual directories. For example, some cache directories of a website need to have write permissions for the http service. For example, the /data/ directory of discuz x2 must have write permissions.

    find data -type d -exec chmod 770 {} \;

Guess you like

Origin blog.csdn.net/qq_45533800/article/details/112546449