我已经读过 http://codex.wordpress.org/Hardening_WordPress但我无法理解它。应该设置什么权限,应该由谁拥有?现在我已经设置为以下命令的结果:
# reset to safe defaults
find /usr/share/wordpress -exec chown www-data:www-data {} \;
find /usr/share/wordpress -type d -exec chmod 755 {} \;
find /usr/share/wordpress -type f -exec chmod 644 {} \;
# allow wordpress to manage wp-config.php (but prevent world access)
chgrp www-data /usr/share/wordpress/wp-config.php
chmod 660 /usr/share/wordpress/wp-config.php
# allow wordpress to manage .htaccess
chgrp www-data /usr/share/wordpress/.htaccess
chmod 664 /usr/share/wordpress/.htaccess
# allow wordpress to manage wp-content
find /usr/share/wordpress/wp-content -exec chgrp www-data {} \;
find /usr/share/wordpress/wp-content -type d -exec chmod 775 {} \;
find /usr/share/wordpress/wp-content -type f -exec chmod 664 {} \;
此配置后安装无法使用。有什么建议吗?
最佳答案
以下是我如何管理服务器权限的快速回顾:
- 任何人都可以读取文件和目录
- 没有人可以在/wp-content/uploads 目录之外写任何东西
- PHP 脚本不能在/wp-content/uploads 目录中执行
- PHP 脚本不能直接在/wp-includes 和/wp-content 中执行
所以谁拥有 .php 文件并不重要,只要 apache 用户可以读取它们即可。允许 apache 用户修改这些文件是有风险的,即使是 .htaccess。所有这一切的缺点是您需要向 WordPress 提供 FTP 凭据才能执行安装或删除插件、更新主题或核心等操作。这是我可以接受的。
关于wordpress - wordpress 安装必须具有哪些权限才能安全但有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12827513/