将文件设置为755,将目录设置为644

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将文件设置为755,将目录设置为644相关的知识,希望对你有一定的参考价值。

This will grep through your file structure (LAMP stack assumed) and change directories and files to the correct permissions to work with suphp.
  1. for i in $(find /home/*/public_html -maxdepth 0); do u=$(echo $i | awk -F '/' '{print $3}') && chown -R $u:$u $i; done
  2. for i in $(grep DocumentRoot /usr/local/apache/conf/httpd.conf | awk '{print $2}' | grep -v /usr/local/apache/htdocs); do chgrp nobody $i; done
  3. find /home/*/public_html -type d -exec chmod 755 '{}' ';'
  4. find /home/*/public_html -type f -exec chmod 644 '{}' ';'
  5. find /home/*/public_html -iwholename '*.cgi' -exec chmod 755 '{}' ';'
  6. find /home/*/public_html -iwholename '*.pl' -exec chmod 755 '{}' ';'

以上是关于将文件设置为755,将目录设置为644的主要内容,如果未能解决你的问题,请参考以下文章

将目录的所有文件和文件夹权限更改为 644/755

如何设置UNIX/Linux中新创建目录或文件的默认权限

chmod只修改子目录或文件的权限

Linux权限详解(chmod、600、644、666、700、711、755、777、4755、6755、7755)

在 Nginx 上运行 WordPress 的权限问题

linux服务器环境安全防范教程