環境
CentOS8、MariaDB 10.3.17、PHP 7.4.13、apache 2.4.37、SELINUX=enforcing
問題
Wordpressのテーマを変更しようとして、「新規追加」ボタンを押すと、エラーが出てテーマを選択できない。
原因
そもそも自分が操作しているクライアントPCとは繋がっており、ファイアーウォールとかではない。ということでSELinuxのログを見るとdenied
の文字が大量に出てる。
# aureport --avc
AVC Report
===============================================================
# date time comm subj syscall class permission obj result event
===============================================================
1. 11/25/2020 19:00:36 ? system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 0 (null) (null) (null) unset 141
2. 11/25/2020 19:34:17 php-fpm system_u:system_r:httpd_t:s0 0 tcp_socket name_connect system_u:object_r:http_port_t:s0 denied 226
...
RedHatのドキュメントによると、SELinuxをdisableにしていない場合、SELinuxはApacheが外部ネットワークと通信するのを許可しない。なので、テーマだけでなくプラグインの追加とか、外部ネットワークとの通信が発生する処理なら全て同じエラーが発生する。
4.4.2. Security-Enhanced Linux
This reference environment has been set up and tested with Security-Enhanced Linux (SELinux) enabled in ENFORCING mode. Once again, please refer to the Red Hat documentation on SELinux for further details on using and configuring this feature. For any other operating system, consult the respective documentation for security and firewall solutions to ensure that maximum security is maintained while the ports required by your application are opened.
When enabled in ENFORCING mode, by default, SELinux prevents Apache web server from establishing network connections. On the machine hosting Apache web server, configure SELinux it to allow httpd network connections:
# /usr/sbin/setsebool httpd_can_network_connect 1