web-dev-qa-db-ja.com

php7.0-fpmをスーパーバイザドで起動するにはどうすればよいですか?

私はApache2でDocker化されたubuntu 16.04ltsとphp7.0-fpmでnginxを構築しようとしています

使用したが機能しなかったコマンド

[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 --daemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

そして

[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm/php-fpm.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

そして

[program:php-fpm7.0]
command = /usr/sbin/php-fpm7.0 -c /etc/php/7.0/fpm
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

以下は、コンテナーとして実行しようとしたときのDockerのエラーログです

apache2コンテナから

2016-06-26 20:04:21,488 CRIT Set uid to user 0
2016-06-26 20:04:21,496 INFO RPC interface 'supervisor' initialized
2016-06-26 20:04:21,496 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-06-26 20:04:21,496 INFO supervisord started with pid 8
2016-06-26 20:04:22,499 INFO spawned: 'php-fpm7.0' with pid 11
2016-06-26 20:04:22,500 INFO spawned: 'Apache2' with pid 12
2016-06-26 20:04:22,571 INFO exited: Apache2 (exit status 0; not expected)
[26-Jun-2016 20:04:22] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:22] ERROR: FPM initialization failed
2016-06-26 20:04:22,609 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:23,611 INFO spawned: 'php-fpm7.0' with pid 74
2016-06-26 20:04:23,613 INFO spawned: 'Apache2' with pid 75
httpd (pid 16) already running
2016-06-26 20:04:23,669 INFO exited: Apache2 (exit status 0; not expected)
[26-Jun-2016 20:04:23] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:23] ERROR: FPM initialization failed
2016-06-26 20:04:23,694 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:25,698 INFO spawned: 'php-fpm7.0' with pid 79
2016-06-26 20:04:25,700 INFO spawned: 'Apache2' with pid 80
httpd (pid 16) already running
2016-06-26 20:04:25,758 INFO exited: Apache2 (exit status 0; not expected)
[26-Jun-2016 20:04:25] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:25] ERROR: FPM initialization failed
2016-06-26 20:04:25,784 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:28,788 INFO spawned: 'php-fpm7.0' with pid 84
2016-06-26 20:04:28,789 INFO spawned: 'Apache2' with pid 85
httpd (pid 16) already running
2016-06-26 20:04:28,847 INFO exited: Apache2 (exit status 0; not expected)
2016-06-26 20:04:28,857 INFO gave up: Apache2 entered FATAL state, too many start retries too quickly
[26-Jun-2016 20:04:28] ERROR: Unable to create the PID file (/run/php/php7.0-fpm.pid).: No such file or directory (2)
[26-Jun-2016 20:04:28] ERROR: FPM initialization failed
2016-06-26 20:04:28,872 INFO exited: php-fpm7.0 (exit status 78; not expected)
2016-06-26 20:04:29,873 INFO gave up: php-fpm7.0 entered FATAL state, too many start retries too quickly

そして

nginxコンテナから

2016-06-26 11:19:02,307 CRIT Set uid to user 0
2016-06-26 11:19:02,320 INFO RPC interface 'supervisor' initialized
2016-06-26 11:19:02,320 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-06-26 11:19:02,321 INFO supervisord started with pid 14
2016-06-26 11:19:03,323 INFO spawned: 'php7.0-fpm' with pid 17
2016-06-26 11:19:03,324 INFO spawned: 'nginx' with pid 18
[26-Jun-2016 11:19:03] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:03] ERROR: FPM initialization failed
2016-06-26 11:19:03,406 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:04,409 INFO spawned: 'php7.0-fpm' with pid 20
2016-06-26 11:19:04,409 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
[26-Jun-2016 11:19:04] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:04] ERROR: FPM initialization failed
2016-06-26 11:19:04,465 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:06,470 INFO spawned: 'php7.0-fpm' with pid 21
[26-Jun-2016 11:19:06] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:06] ERROR: FPM initialization failed
2016-06-26 11:19:06,527 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:09,532 INFO spawned: 'php7.0-fpm' with pid 30
[26-Jun-2016 11:19:09] ERROR: unable to bind listening socket for address '/run/php/php7.0-fpm.sock': No such file or directory (2)
[26-Jun-2016 11:19:09] ERROR: FPM initialization failed
2016-06-26 11:19:09,592 INFO exited: php7.0-fpm (exit status 78; not expected)
2016-06-26 11:19:10,594 INFO gave up: php7.0-fpm entered FATAL state, too many start retries too quickly
2016/06/26 11:19:13 [info] 19#19: *1 client closed connection while waiting for request, client: 192.168.99.1, server: 0.0.0.0:80

だから私の質問は、どのようにsupervisordを使用してphp7.0-fpm/php-fpm7.0をdockerコンテナーで正しく起動するかです。

また、これらのコンテナーにログインしてこのコマンドを実行すると、動作が開始されることも理解してください!

service php7.0-fpm start

コンテナーの実行時にfpmが起動に失敗した後に上記のコマンドを実行すると、機能します。 しかし、これをスーパーバイザでどのように行うのですか?したがって、手動でinit.dから開始する必要はありません。

3
uberrebu

/run/php/php7.0-fpm.pidファイルがないようです。このファイルは、php7.0-fpmの起動時に作成されます。だから私はDockerfileに追加することでこの問題を解決しました:

 RUNサービスphp7.0-fpm start 

もちろん、php-fpmのインストール後:)

5
limestreet

ビルドで/var/run/php、つまりmkdir -p /var/run/phpを作成し、php-fpmを監視対象で開始する

[supervisord]
nodaemon=true

[program:php-fpm]
command=/usr/sbin/php-fpm7.0 -F
autostart=true
autorestart=unexpected
stdout_logfile=/var/log/php-fpm/stdout.log
stdout_logfile_maxbytes=0
stderr_logfile=/var/log/php-fpm/stderr.log
stderr_logfile_maxbytes=0
exitcodes=0

また働きます。

上記をコピーして貼り付ける場合は、スーパーバイザがログファイルを書き込むためのmkdir -p /var/log/php-fpmも必ず確認してください。

13
Jonathan