gotchaphpdockerModerate
What is the difference between php-cli and php-fpm, why 2 php variants and why choose one or the other?
Viewed 0 times
whythewhatphpchoosefpmdifferencevariantsbetweenone
Problem
Looking at https://hub.docker.com/_/php I can see reference to
Now, I am aware of the concepts of PHP FPM - Fast CGI Process Manager. I'm also aware the PHP can be run in the command line and for php composer and Symfony console.
Does the Docker
Why would one choose one or the other?
Thank you.
php-cli and php-fpm.Now, I am aware of the concepts of PHP FPM - Fast CGI Process Manager. I'm also aware the PHP can be run in the command line and for php composer and Symfony console.
Does the Docker
php-fpm not have PHP CLI tools like php-fpm. Or is php-fpm a superset of php-cli ?Why would one choose one or the other?
Thank you.
Solution
They are different tools for different purposes:
-
php-cli is the standalone tool for running a PHP scripts in the same way you would run it from the command line:
This variant contains the PHP CLI tool with default mods. If you need a web server, this is probably not the image you are looking for. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as a base from which to build other images.
-
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.
You also have two other variants:
You can see all of the Dockerfiles on GitHub and whilst it doesn't appear that
-
php-cli is the standalone tool for running a PHP scripts in the same way you would run it from the command line:
php somescript.php. It seems you can also use it to base other images from.This variant contains the PHP CLI tool with default mods. If you need a web server, this is probably not the image you are looking for. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as a base from which to build other images.
-
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.
You also have two other variants:
- php-apache which is just Apache configured with
mod_php
- php-alpine is the smallest possible Docker image based upon Alpine Linux, albeit with some compatibility issues.
You can see all of the Dockerfiles on GitHub and whilst it doesn't appear that
php-fpm is based upon php-cli practically they are likely to be very similar and php-fpm is probably a superset of php-cli.Context
StackExchange DevOps Q#9505, answer score: 15
Revisions (0)
No revisions yet.