Docker上でなぜかphp-fpmが立ち上がらないので、wordpressが表示されない件
調査内容
SUB PC のDockerでなぜかphp-fpmが立ち上がらないので、wordpressが表示されない。503エラーが出る。
エラー内容
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
→エラー
C:\Users\r2d2>docker exec -it myu bash
[root@b892dfb99468 /]# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2021-03-15 04:43:07 UTC; 7min ago
Process: 51 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
Main PID: 51 (code=exited, status=78)
Mar 15 04:43:07 b892dfb99468 systemd[1]: Starting The PHP FastCGI Process Manager...
Mar 15 04:43:07 b892dfb99468 php-fpm[51]: [15-Mar-2021 04:43:07] ERROR: [pool www] failed to read the ACL of the socket '/run/php-fpm/www.sock': Operation n>
Mar 15 04:43:07 b892dfb99468 php-fpm[51]: [15-Mar-2021 04:43:07] ERROR: FPM initialization failed
Mar 15 04:43:07 b892dfb99468 systemd[1]: php-fpm.service: Main process exited, code=exited, status=78/CONFIG
Mar 15 04:43:07 b892dfb99468 systemd[1]: php-fpm.service: Failed with result 'exit-code'.
Mar 15 04:43:07 b892dfb99468 systemd[1]: Failed to start The PHP FastCGI Process Manager.
lines 1-12/12 (END)
対処方法
php-fpmのconfファイルを編集してみる
[root@b894e9a3cdae php-fpm.d]# vim /etc/php-fpm.d/www.conf
28 ; The address on which to accept FastCGI requests.
29 ; Valid syntaxes are:
30 ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
31 ; a specific port;
32 ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
33 ; a specific port;
34 ; 'port' - to listen on a TCP socket to all addresses
35 ; (IPv6 and IPv4-mapped) on a specific port;
36 ; '/path/to/unix/socket' - to listen on a unix socket.
37 ; Note: This value is mandatory.
38 listen = /run/php-fpm/www.sock
39
40 ; Set listen(2) backlog.
41 ; Default Value: 511
42 ;listen.backlog = 511
43
44 ; Set permissions for unix socket, if one is used. In Linux, read/write
45 ; permissions must be set in order to allow connections from a web server.
46 ; Default Values: user and group are set as the running user
47 ; mode is set to 0660
48 ;listen.owner = nobody
49 ;listen.group = nobody
50 ;listen.mode = 0660
51
52 ; When POSIX Access Control Lists are supported you can set them using
53 ; these options, value is a comma separated list of user/group names.
54 ; When set, listen.owner and listen.group are ignored
55 ;listen.acl_users = apache,nginx ※コメントアウト
56 ;listen.acl_groups =
php-fpmが立ちあがるようになった!
[root@b894e9a3cdae /]# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2021-03-27 00:54:20 UTC; 10h ago
Main PID: 871 (php-fpm)
Status: "Processes active: 0, idle: 9, Requests: 66, slow: 0, Traffic: 0req/sec"
Tasks: 10 (limit: 11905)
Memory: 209.1M
CGroup: /docker/b894e9a3cdae0d8e2e70b9dec604d95ea0e54523c98aa36a7cb0c30b1cd1914a/system.slice/php-fpm.service
├─871 php-fpm: master process (/etc/php-fpm.conf)
├─872 php-fpm: pool www
├─873 php-fpm: pool www
├─874 php-fpm: pool www
├─875 php-fpm: pool www
├─876 php-fpm: pool www
├─951 php-fpm: pool www
├─954 php-fpm: pool www
├─986 php-fpm: pool www
└─989 php-fpm: pool www
Mar 27 00:54:20 b894e9a3cdae systemd[1]: Starting The PHP FastCGI Process Manager...
Mar 27 00:54:20 b894e9a3cdae systemd[1]: Started The PHP FastCGI Process Manager.
まだアクセスエラーがでる。
$ curl -I
HTTP/1.1 503 Service Unavailable
Date: Fri, 26 Mar 2021 23:39:34 GMT
Server: Apache/2.4.37 (centos)
Connection: close
Content-Type: text/html; charset=iso-8859-1
/etc/httpd/logs/error_log はこんな感じ
178 [Sat Mar 27 00:31:07.666010 2021] [proxy:error] [pid 485:tid 140454632851200] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /run/php-fpm/www.soc
179 [Sat Mar 27 00:31:07.666088 2021] [proxy_fcgi:error] [pid 485:tid 140454632851200] [client 172.17.0.1:59184] AH01079: failed to make connection to backend: httpd-UDS
180 [Sat Mar 27 00:31:07.986197 2021] [proxy:error] [pid 483:tid 140454448310016] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /run/php-fpm/www.soc
181 [Sat Mar 27 00:31:07.986271 2021] [proxy_fcgi:error] [pid 483:tid 140454448310016] [client 172.17.0.1:59188] AH01079: failed to make connection to backend: httpd-UDS, referer: h~
パーミッションっぽい
rootからapacheにオーナーを変えてみる。
chown apache:apache /run/php-fpm/www.sock
[root@b894e9a3cdae /]# ls -lha /run/php-fpm/
total 4.0K
drwxr-xr-x 2 root root 80 Mar 27 00:54 .
drwxr-xr-x 18 root root 400 Mar 27 00:54 ..
-rw-r--r-- 1 root root 3 Mar 27 00:54 php-fpm.pid
srw-rw---- 1 apache apache 0 Mar 27 00:54 www.sock
画面から見れるようになった!
$ curl -I
HTTP/1.1 200 OK
Date: Sat, 27 Mar 2021 12:10:58 GMT
Server: Apache/2.4.37 (centos)
X-Powered-By: PHP/7.2.24
Link: </wp-json/>; rel="https://api.w.org/"
Content-Type: text/html; charset=UTF-8