AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1070342
Accepted
Vinícius Ferrão
Vinícius Ferrão
Asked: 2021-07-23 09:32:52 +0800 CST2021-07-23 09:32:52 +0800 CST 2021-07-23 09:32:52 +0800 CST

允许使用 nginx/php-fpm 在 EL8 中使用 SELinux 升级 Wordpress

  • 772

我正在尝试允许直接在 Web 界面上使用 Wordpress 升级(不是插件更新)。

除了这个特性之外,我已经让 SELinux 可以工作。当试图确定应该允许的内容时,我无法准确找到需要更改的内容,而不是将整个重新标记/path/to/wordpress/directory为unconfined_u:object_r:httpd_sys_rw_content_t:s0

以下是我尝试通过 Web 界面升级时发生的情况:

==> /var/log/nginx/kosen.energy.access.log <==
172.21.1.28 - - [22/Jul/2021:14:21:27 -0300] "POST /wp-cron.php?doing_wp_cron=1626974487.4410700798034667968750 HTTP/1.0" 200 0 "https://kosen.energy/wp-cron.php?doing_wp_cron=1626974487.4410700798034667968750" "WordPress/5.7.2; https://kosen.energy"
172.21.1.28 - - [22/Jul/2021:14:21:29 -0300] "GET /wp-admin/update-core.php HTTP/1.0" 200 155053 "https://kosen.energy/wp-admin/update-core.php?action=do-core-upgrade" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"

==> /var/log/audit/audit.log <== type=AVC msg=audit(1626974498.501:10696): avc:  denied  { write } for  pid=9658 comm="php-fpm" name="update-core.php" dev="dm-0" ino=101266980 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:httpd_sys_content_t:s0 tclass=file permissive=0

==> /var/log/nginx/error.log <== 2021/07/22 14:21:38 [error] 9646#0: *38349 FastCGI sent in stderr: "PHP message: PHP Warning:  copy(/var/www/html/kosen.energy/wp-admin/includes/update-core.php): failed to open stream: Permission denied in /var/www/html/kosen.energy/wp-admin/includes/class-wp-filesystem-direct.php on line 309" while reading upstream, client: 172.21.1.28, server: _, request: "POST /wp-admin/update-core.php?action=do-core-upgrade HTTP/1.0", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "kosen.energy", referrer: "https://kosen.energy/wp-admin/update-core.php"

==> /var/log/nginx/kosen.energy.access.log <==
172.21.1.28 - - [22/Jul/2021:14:21:38 -0300] "POST /wp-admin/update-core.php?action=do-core-upgrade HTTP/1.0" 200 150059 "https://kosen.energy/wp-admin/update-core.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"

在我wp-config.conf已经有了FS_METHOD:direct

/** Enable proper support for updates without FTP/FTPS. */
define('FS_METHOD', 'direct');

php-fpm已经以nginx用户身份运行:

[root@kosen kosen.energy]# grep user /etc/php-fpm.d/www.conf | grep -v \;
user = nginx
listen.acl_users = apache,nginx

附加信息:

[root@kosen kosen.energy]# rpm -qa | egrep "php-fpm|nginx"
nginx-mod-http-xslt-filter-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.x86_64
nginx-mod-http-image-filter-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.x86_64
nginx-mod-http-perl-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.x86_64
nginx-mod-mail-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.x86_64
nginx-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.x86_64
nginx-all-modules-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.noarch
nginx-filesystem-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.noarch
nginx-mod-stream-1.14.1-9.0.1.module+el8.0.0+5347+9282027e.x86_64
php-fpm-7.4.6-4.module+el8.3.0+7685+72d70b58.x86_64

谢谢。

nginx wordpress php-fpm selinux rhel8
  • 1 1 个回答
  • 195 Views

1 个回答

  • Voted
  1. Best Answer
    Michael Hampton
    2021-07-23T09:41:22+08:002021-07-23T09:41:22+08:00

    所有 WordPress 文件都必须是可写的,才能使用管理网页的升级功能。我不这样做;我使用wp命令直接在服务器上升级 WordPress。

    wp core update
    wp core update-db
    
    • 1

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve