Web site root permissions set

  
Root directory permissions settings

For security, we need to use specific users and user groups to run the web server. In accordance with normal practice, we are thrown back to use the www user group. The www user to run the web server, whether it is nginx or apache, we can do this.

The server running on the www user needs to read various resources of the website root directory, including dynamic scripts, such as php scripts, or html, css, javaScript and other files. Of course, we can also execute special scripts by switching to other users in the php script, which is the same as switching users in shell scripts.

What happened when nginx executed PHP code? Share it with you later

Set website root permissions

chown -R www.www /data/wwwroot/# Modify the user and user group of the website root directory

find /data/wwwroot/-type d -exec chmod 755 {} \\; #The permissions of the directory is 755

find /data/wwwroot /-type f -exec chmod 644 {} \\; #文件's permission is 644

If www.www does not exist, you need to create it first

Copyright © Windows knowledge All Rights Reserved