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

王林
Release: 2020-11-16 15:55:59
forward
4091 people have browsed it

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
Copy after login

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 {} \;
Copy after login

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 {} \;
Copy after login

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 {} \;
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template