The recommended way to get the Exira PHP-FPM Docker Image is to pull the prebuilt image from the Docker Hub Registry.
docker pull exira/php-fpm:latest
To use a specific version, you can pull a versioned tag. You can view the list of available versions in the Docker Hub Registry.
docker pull exira/php-fpm:[TAG]
If you wish, you can also build the image yourself.
git clone https://github.com/exira/docker-php-fpm.git
cd docker-php-fpm
docker build -t exira/php-fpm .
This image is designed to be used with a web server to serve your PHP app, you can use the linking system provided by Docker to do this.
We will use PHP-FPM with nginx to serve our PHP app. Doing so will allow us to setup more complex configuration, serve static assets using nginx, load balance to different PHP-FPM instances, etc.
Let's create an nginx virtual host to reverse proxy to our PHP-FPM container. The exira nginx Docker Image ships with some example virtual hosts for connecting to exira runtime images. We will make use of the PHP-FPM example:
server {
listen 0.0.0.0:80;
server_name yourapp.com;
access_log /exira/nginx/logs/yourapp_access.log;
error_log /exira/nginx/logs/yourapp_error.log;
root /app;
location / {
index index.php;
}
location ~ \.php$ {
# fastcgi_pass [PHP_FPM_LINK_NAME]:9000;
fastcgi_pass yourapp:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
Notice we've substituted the link alias name yourapp, we will use the same name when creating the link.
Copy the virtual host above, saving the file somewhere on your host. We will mount it as a volume in our nginx container.
Docker's linking system uses container ids or names to reference containers. We can explicitly specify a name for our PHP-FPM server to make it easier to connect to other containers.
docker run -it --name phpfpm -v /path/to/php/app:/app exira/php-fpm
or using Docker Compose:
phpfpm:
image: exira/php-fpm
volumes:
- /path/to/php/app:/app
Now that we have our PHP-FPM server running, we can create another container that links to it by giving Docker the --link option. This option takes the id or name of the container we want to link it to as well as a hostname to use inside the container, separated by a colon. For example, to have our PHP-FPM server accessible in another container with yourapp as it's hostname we would pass --link phpfpm:yourapp to the Docker run command.
docker run -it -v /path/to/vhost.conf:/exira/nginx/conf/vhosts/yourapp.conf \
--link phpfpm:yourapp \
exira/nginx
or using Docker Compose:
nginx:
image: exira/nginx
links:
- phpfpm:yourapp
volumes:
- /path/to/vhost.conf:/exira/nginx/conf/yourapp.conf
We started the nginx server, mounting the virtual host we created in Step 1, and created a link to the PHP-FPM server with the alias yourapp.
Content type
Image
Digest
Size
44 MB
Last updated
about 10 years ago
docker pull exira/php-fpm:5.6.21