我正在尝试更新 WordPress 插件,但收到此错误消息:
Update failed: Could not create directory. /var/www/html/wp-content/upgrade/akismet.5.3
当我转到“工具”>“站点运行状况”>“信息”>“文件权限”时,我会看到以下内容:
如何使这些目录可写?我以为可以通过递归使用 755 来实现
/var/www/html/wp-content
,但我已经拥有这些权限,但它仍然无法正常工作。
问题出在运行 Apache 的用户上。为了解决这个问题,我打开了这个文件:
/etc/apache2/envvars
,我注释掉了几行,将它们替换为我想要运行 Apache 的用户:
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
#export APACHE_RUN_USER=www-data
export APACHE_RUN_USER=jmontoya
#export APACHE_RUN_GROUP=www-data
export APACHE_RUN_GROUP=jmontoya
然后我用
sudo service apache2 restart
重新启动了 Apache。
我确认 Apache 现在正在以我所需的用户身份运行:
ps axo user,group,comm | egrep '(apache|httpd)'
root root apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
/var/www/html/wp-content
中的所有内容也属于jmontoya
,我用chown
指定它。使用 chmod
正确定义权限。
现在我看到了我所期望的: