Home  >  Article  >  Operation and Maintenance  >  How to correctly configure apache to read and write permissions on the website directory

How to correctly configure apache to read and write permissions on the website directory

王林
王林forward
2020-11-16 15:55:593936browse

How to correctly configure apache to read and write permissions on the website directory

Premise:

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

(Video tutorial recommendation: php video tutorial)

Specific method:

1. First, set the owner and owner of the website directory and files All groups are centos,www.

For example:

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

2. Set the website directory permissions to 750. 750 means that the centos user has read, write and execute permissions on the directory.

In this way, centos users can create files in any directory. The user group has read and execute permissions so that they can enter the directory. Other users do not have any permissions.

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

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

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

4. Set writable permissions for individual directories.

For example, some cache directories of the 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 {} \;

You must have noticed the wonderful use of the find command in the above configuration.

When operating files in multi-level directories, especially when searching for files and setting permissions, the find command is still very useful.

Related recommendations: apache

The above is the detailed content of How to correctly configure apache to read and write permissions on the website directory. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete