php
php copied to clipboard
Can't listen on socket
I'd like to use the php-fpm container with socket listener(more secure I think) instead of tcp. I run my instance like this:
docker run -d \
-e TZ=${MY_TIMEZONE} \
--name php-fpm-8.4 \
--network ${DOCKER_NETWORK} \
--restart=unless-stopped \
-v ${DOCKER_CONTAINER_DIR}/htdocs:/srv/www \
-v ${DOCKER_CONTAINER_DIR}/php/run:/run/php \
-v ${DOCKER_CONTAINER_DIR}/php/my-fpm-pool.conf:/usr/local/etc/php-fpm.d/www.conf \
php:8.4-fpm
So, I override the www.conf with my customized FPM pool config which contains a "listen = /run/php/php.sock". When the container started there was no socket. After several minutes I found the mistake in file /usr/local/etc/php-fpm.d/zz-docker.conf. It redefines the "www" pool listen setting to tcp. Contents of the file:
[global]
daemonize = no
[www]
listen = 9000
Why this file exists? Why is it needed to contain "listen = 9000"?
Good point -- we need to make sure daemonize = no is as late as possible, but listen = 9000 could be higher. 🤔
I just wasted few hours trying to understand why unix socket does not created after php-fpm is started. Is it any specific reason to override listen parameter for www pool? This invalidates any changes to the listen parameter in the pool configuration file. Which is confusing and error-prone.