07 Configuring PHP FPM - dchantzis/sfh-docker-in-development-part-1 GitHub Wiki

Source: https://serversforhackers.com/c/div-configuring-php-fpm

We need to add some custom PHP configuration, especially so it does not run as a daemon.

> docker run -d --rm -p 8080:80 -v %cd%/application:/var/www/html/public shippingdocker/app:latest
> docker exec -it <CONTAINER_ID> bash
> cd /etc/php/7.2/fpm
> cat php-fpm.conf | grep daemon
> exit

Now we will copy the php-fpm.conf from inside the Container to our local docker/app directory:

> docker exec -it <CONTAINER_ID> cat /etc/php/7.2/fpm/php-fpm.conf

Then we will update the php-fpm.conf file by setting daemonize = no and add the following line in the Dockerfile:

ADD php-fpm.conf /etc/php/7.2/fpm/php-fpm.conf

We will need to rebuild the Image and run the Container:

> docker build -t shippingdocker/app:latest -f docker/app/Dockerfile docker/app
> docker run -it --rm -p 8080:80 -v %cd%/application:/var/www/html/public shippingdocker/app:latest

We will se in the output that php-fpm is running:

2020-03-18 09:28:55,294 INFO spawned: 'nginx' with pid 8
2020-03-18 09:28:55,295 INFO spawned: 'php-fpm' with pid 9
2020-03-18 09:28:56,330 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-18 09:28:56,331 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)