Although we are more free to set up a website on VPS, we need to do the security settings of the space ourselves. Once the website space or webpage is insecure, other websites may be affected by Elevation of Privilege. Of course, we do not know much about security. This is mainly because I encountered a problem this morning, because the transferred website files are all 777 permissions, and then moved to the host, resulting in a 403 error message. This requires us to set 755 for all folders, set 644 for all webpage files. Many people will find that if you manually set
Although we are more free to set up a website on VPS, we need to do the security settings of the space ourselves. Once the website space or webpage is insecure, other websites may be affected by Elevation of Privilege. Of course, we do not know much about security. This is mainly because I encountered a problem this morning, because the transferred website files are all 777 permissions, and then moved to the host, resulting in a 403 error message. This requires us to set 755 for all folders, set 644 for all webpage files.
Many people will find it very troublesome to manually set the folder because there are folders and files under each folder. Is there a command that can be set directly?
SSH command method 1
find . -exec sh -c "if [[ -d "{}" ]]; then chmod 755 "{}"; else chmod 644 "{}"; fi " \;
SSH command method 2
find ./ -type d -print|xargs chmod 755;find ./ -type f -print |xargs chmod 644
Any of the above methods can solve the problem of setting folder 755 and webpage file 644 permissions.