我正在使用wordpress 5.4.2在ubuntu 18.04上运行LAMP开发环境。我发现this awesome script 旨在轻松调整wordpress安装的权限,在快照中消除403个错误。然而,我一直在尝试让脚本在我的系统上运行。我确信我犯了一个简单的错误,但我不是一个程序员。以下是作者的每一个重要道具的原创精彩剧本:
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # <-- wordpress owner
WP_GROUP=changeme # <-- wordpress group
WP_ROOT=/home/changeme # <-- wordpress root directory
WS_GROUP=changeme # <-- webserver group
# reset to safe defaults
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \\;
find ${WP_ROOT} -type d -exec chmod 755 {} \\;
find ${WP_ROOT} -type f -exec chmod 644 {} \\;
# allow wordpress to manage wp-config.php (but prevent world access)
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 660 ${WP_ROOT}/wp-config.php
# allow wordpress to manage .htaccess
touch ${WP_ROOT}/.htaccess
chgrp ${WS_GROUP} ${WP_ROOT}/.htaccess
chmod 664 ${WP_ROOT}/.htaccess
# allow wordpress to manage wp-content
find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \\;
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \\;
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \\;
[1]: https://gist.github.com/macbleser/9136424
以下是我根据托管提供商的权限所做的编辑:
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=/var/www/html/<wp root directory>/ # <-- wordpress root directory
WS_GROUP=www-data # <-- webserver group
# reset to safe defaults
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \\;
find ${WP_ROOT} -type d -exec chmod 755 {} \\;
find ${WP_ROOT} -type f -exec chmod 644 {} \\;
# allow wordpress to manage wp-config.php (but prevent world access)
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 644 ${WP_ROOT}/wp-config.php
# allow wordpress to manage .htaccess
touch ${WP_ROOT}/.htaccess
chgrp ${WS_GROUP} ${WP_ROOT}/.htaccess
chmod 644 ${WP_ROOT}/.htaccess
# allow wordpress to manage wp-content
find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \\;
find ${WP_ROOT}/wp-content -type d -exec chmod 755 {} \\;
find ${WP_ROOT}/wp-content -type f -exec chmod 644 {} \\;
我使用
sudo chmod +x wp-permissions.sh
为了使脚本可以执行,并且执行起来没有问题,但每次我访问网站时,都会遇到403错误。我可以成功重启apache和mysql,所以问题肯定是权限问题。关于我做错了什么有什么建议吗?