0

I am creating a Docker image that run NginX and PHP-FPM (with Supervisor). The container is run as www-data, but the PHP-FPM socket is not created.

Here are my config files :

www.conf

[www]
listen = /var/run/php/php7.3-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

user = www-data
group = www-data

pm = ondemand
pm.max_children = 72
pm.process_idle_timeout = 10s;
pm.max_requests = 1000

mywebsite.conf

server {
    ...
    location ~ \.php$ {
        try_files $uri $uri/ /doku.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param REDIRECT_STATUS 200;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    }
    ...
}

Supervisor conf : PHP-FPM

[program:php-fpm]
command=php-fpm
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
stdout-encoding=utf-8

Supervisor conf : NginX

[program:nginx]
command=nginx -g "daemon off;"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true

supervisord.conf

[unix_http_server]
file=/opt/run/supervisord.sock   ; (the path to the socket file)
username = dummy
password = dummy

[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
loglevel=info                ; (log level;default info; others: debug,warn,trace)
user = www-data
pidfile = /opt/run/supervisord.pid

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///run/supervisord.sock ; use a unix:// URL  for a unix socket
username = dummy
password = dummy

[include]
files = /etc/supervisor/conf.d/*.conf

Thank you by advance

  • 1
    Why a single container? The normal approach is to create separate containers for nginx and php-fpm. – Michael Hampton Apr 14 at 19:41
  • Yes, it's true, but In my case, I need this approach becase I am creating microservices and I use Gravitee.io + Consul.io. To use the load balancing system with Gravitee and Consul, I need PHP-FPM and NginX on a single container – M4kn4sh Apr 14 at 20:26
  • Huh? Are you following some documentation? I can't find any example for gravitee or consul which requires php-fpm? – Michael Hampton Apr 14 at 20:35
  • No, microservices are developed in PHP. Before Gravitee, I had several php-fpm containers and one nginx container. In this case, if I want to use health checks with Gravitee, it was more difficult. – M4kn4sh Apr 14 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.