nginx 与 php-fpm

xiaoxiao2021-02-28  21

Nginx不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用。FastCGI接口在Linux下是socket(这个socket可以是unix socket,也可以是tcp socket)。为了调用FastCGI接口,还需要一个管理FastCGI的wrapper(FastCGI是一个文件,当这个文件写入内容时,wrapper Fork派生出一个新的线程,这个线程调用解释器或者外部程序处理脚本并读取返回数据 ) php-fpm 是nginx 与php之间的wrapper ,是一个FastCGI 进程管理器;php-fpm提供了的php进程管理方式,可以有效控制内存和进程、平滑重载PHP配置。

配置

tcp socket

location ~ \.php$ { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; }

unix socket

location ~ \.php$ { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;; fastcgi_pass unix:/run/php7.2-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
转载请注明原文地址: https://www.6miu.com/read-2629039.html

最新回复(0)