What is the relationship between PHP-CLI and php-fpm?
In addition, there is a php-zts, Baidu called "Thread-safe version."
So, which of these three things to use, can you tell them about their usage?
https://hub.docker.com/_/php/
Reply content:
What is the relationship between PHP-CLI and php-fpm?
In addition, there is a php-zts, Baidu called "Thread-safe version."
So, which of these three things to use, can you tell them about their usage?
https://hub.docker.com/_/php/
The CLI is a command-line version.
FPM is an extension of PHP files that are processed as server software such as Apache or Nginx.
The default version of PHP is not thread-safe, and this thread-safety issue can be used to understand the development of PHP extensions because of the C language problem.
The CLI and FPM are two ways of running PHP, while thread-safe and non-thread-safe should be the version. Whether to turn on thread safety is a choice when compiling PHP.
Simply understand, the CLI is what you run PHP on the command line, and FPM is used for Web Access
The CLI is the PHP command we use at the command line, but it can also provide an HTTP service because it has a built-in HTTP server:
php -S 127.0.0.1:80 -t /www /www/index.php
This creates a single-process HTTP service that listens on port 80 on the 127.0.0.1 and has a root directory of/www, which can be used for PHP development and testing.
Where index.php is a rewrite rule that can be implemented in PHP, such as:
上面这段PHP代码跟采用index.php作为前端控制器(路由)的框架的Nginx重写规则含义相近.
location / { try_files $uri $uri/ /index.php?$args;}
php-fpm是一个多进程架构的FastCGI服务,内置php解释器,进程后台常驻,自带进程管理器,支持进程池配置,多配合Nginx使用.
Linux上自行编译的PHP默认是非线程安全的,什么时候需要线程安全呢?
比如你要使用pthreads这个PHP多线程PECL扩展,
或者你的PHP跑在一个多线程的容器内,比如Apache event MPM,这是一个多线程的MPM.