7.0.5., 7.0, latest (Dockerfile)PHP-FPM (FastCGI Process Manager) is an alternative FastCGI implementation for PHP, bundled with the official PHP distribution since version 5.3.3. When compared to the older FastCGI implementation, it contains some additional features, mostly useful for heavily loaded web servers.
PHP is installed under /php
/php # tree -d
/ # tree -d -L 1 /php/
/php/
├── bin
├── conf.d
├── etc
├── include
├── lib
├── log
├── php
├── sbin
└── var
9 directories
This container will be used along with jfusterm/nginx to serve PHP applications.
In this scenario we will have one container with Nginx and another one with PHP-FPM.
We have to use the environmental variable PHPFPM to pass the PHP-FPM service detail using the format IP:PORT
$ docker run -d --name phpfpm01 -v /dir/php-code:/nginx/html -v /php -p 9000:9000 jfusterm/php-fp
$ docker run -d --name nginx -p 80:80 -v /dir/php-code:/nginx/html --link phpfpm01 -e PHPFPM=phpfpm01:9000 jfusterm/nginx
In this scenario we will have one container with Nginx and multiple PHP-FPM containers serving the application. In this case Nginx will act not only as a web server but as a load balancer for the PHP-FPM pool.
$ docker run -d --name phpfpm01 -v /dir/php-code:/nginx/html -p 9001:9000 jfusterm/php-fpm
$ docker run -d --name phpfpm02 -v /dir/php-code:/nginx/html -p 9002:9000 jfusterm/php-fpm
$ docker run -d --name phpfpm03 -v /dir/php-code:/nginx/html -p 9003:9000 jfusterm/php-fpm
Once launched the PHP-FPM containers we can connect to them using their private IP or using the host IP.
First we will get each IP.
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' phpfpm01
172.17.0.3
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' phpfpm02
172.17.0.4
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' phpfpm03
172.17.0.5
Since we connect directly to the containers, we can use the port 9000 directly.
$ docker run -d --name nginx -p 80:80 -v /dir/php-code:/nginx/html -e PHPFPM=172.17.0.3:9000,172.17.0.4:9000,172.17.0.5:9000 jfusterm/nginx
In this case we will use the host IP and its redirected ports.
$ docker run -d --name nginx -p 80:80 -v /dir/php-code:/nginx/html -e PHPFPM=HOST_IP:9001,HOST_IP:9002,HOST_IP:9003 jfusterm/nginx
Obviously we can connect to another PHP-FPM container no matter what their server location is.
Content type
Unrecognized
Digest
Size
44.6 MB
Last updated
over 10 years ago
docker pull jfusterm/php-fpm