Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between apache vs fpm in PHP Docker image?

Tags:

php

docker

At the PHP Docker hub, there's 7.3-apache-stretch and 7.3-fpm-stretch, what's the difference? Which one is suited for a webapp?

like image 574
IMB Avatar asked Jan 19 '19 19:01

IMB


People also ask

How to set up Nginx and PHP-FPM in Docker?

Run the docker ps -a command to check if the container is running. Let us now discuss how you can set up the PHP-FPM and Nginx containers. We begin with getting a server that will act as the container to run the official Nginx image. We will create a docker-compose.yml to run our latest Nginx image. We will utilize ports 80 and 8080.

What is the difference between Apache and FPM?

10 the apache image can be directly exposed, whereas the fpm image needs another web server that then connects to fpm to put it into perspective - the following docker-compose are almost identical (the second one requires a vhost to be added but I think you get the idea):

How do I get the Bitnami PHP-FPM Docker image?

The recommended way to get the Bitnami PHP-FPM Docker Image is to pull the prebuilt image from the Docker Hub Registry. To use a specific version, you can pull a versioned tag. You can view the list of available versions in the Docker Hub Registry. If you wish, you can also build the image yourself.

What is @PHP-FPM?

php-fpm is the FastCGI server implementation of PHP which you would use with a FastCGI compliant web server such as Apache or Nginx. This variant contains PHP-FPM, which is a FastCGI implementation for PHP. See the PHP-FPM website for more information about PHP-FPM.


2 Answers

the apache image can be directly exposed, whereas the fpm image needs another web server that then connects to fpm

to put it into perspective - the following docker-compose are almost identical (the second one requires a vhost to be added but I think you get the idea):

php with apache:

services:
   php:
       image: php:7.3-apache-stretch
       ports:
           - 80

php with fpm (requires apache / nginx to work):

services:
   php:
       image: php:7.3-fpm-stretch
   apache:
       image: apache
       ports:
           - 80
       links:
           - php

as you can see the fpm version gives you more control - ie to use a different webserver

like image 58
wodka Avatar answered Oct 13 '22 12:10

wodka


The 7.3-fpm-stretch variant contains just PHP FPM, while 7.3-apache-stretch contains also Apache httpd server and PHP configured as Apache module.

If you want to use PHP as Apache module, the apache variant may be suited for you.

If you want to use for example nginx or you just want to have FPM, you need the fpm variant.

like image 33
Jakub Matczak Avatar answered Oct 13 '22 12:10

Jakub Matczak