What is the relationship between PHP-CLI and php-fpm?

Source: Internet
Author: User
Keywords Php
Tags zts
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.