分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

[Linux]PHP-FPM与NGINX的两种通讯方式

发布时间:2023-09-06 02:12责任编辑:沈小雨关键词:PHPLinux

一、通过监听TCP端口通讯

php-fpm.d/www.conf

; The address on which to accept FastCGI requests.; Valid syntaxes are:; ??‘ip.add.re.ss:port‘ ???- to listen on a TCP socket to a specific IPv4 address on; ???????????????????????????a specific port;; ??‘[ip:6:addr:ess]:port‘ - to listen on a TCP socket to a specific IPv6 address on; ???????????????????????????a specific port;; ??‘port‘ ????????????????- to listen on a TCP socket to all addresses; ???????????????????????????(IPv6 and IPv4-mapped) on a specific port;; ??‘/path/to/unix/socket‘ - to listen on a unix socket.; Note: This value is mandatory.listen = 127.0.0.1:9000

nignx.conf

location ~ \.php { ???????????root ??????????/lroot/wwwroot/test; ???????????fastcgi_pass ??127.0.0.1:9000; ???????????fastcgi_index ?index.php; ???????????fastcgi_split_path_info ^(.+\.php)(.*)$; ???????????fastcgi_param PATH_INFO $fastcgi_path_info; ???????????fastcgi_param ?SCRIPT_FILENAME ?$document_root$fastcgi_script_name; ???????????include ???????fastcgi_params; ???????}

二、通过unix socket进程间通讯

先选定一个目录创建一个空.sock文件,例如/run/php-fpm.sock(注意不应选用/tmp目录),再进行配置

php-fpm.d/www.conf

1.设置通讯方式

; The address on which to accept FastCGI requests.; Valid syntaxes are:; ??‘ip.add.re.ss:port‘ ???- to listen on a TCP socket to a specific IPv4 address on; ???????????????????????????a specific port;; ??‘[ip:6:addr:ess]:port‘ - to listen on a TCP socket to a specific IPv6 address on; ???????????????????????????a specific port;; ??‘port‘ ????????????????- to listen on a TCP socket to all addresses; ???????????????????????????(IPv6 and IPv4-mapped) on a specific port;; ??‘/path/to/unix/socket‘ - to listen on a unix socket.; Note: This value is mandatory.listen = /run/php-fpm.sock

2.设置创建.sock文件的访问权限,以便nginx进程能够访问php-fpm创建的.sock

; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user‘s group; ??????will be used.user = nginxgroup = nginx
; Set permissions for unix socket, if one is used. In Linux, read/write; permissions must be set in order to allow connections from a web server. Many; BSD-derived systems allow connections regardless of permissions.; Default Values: user and group are set as the running user; ????????????????mode is set to 0660listen.owner = nginxlisten.group = nginxlisten.mode = 0660

nignx.conf

location ~ \.php { ???????????root ??????????/lroot/wwwroot/test; ???????????fastcgi_pass ??unix:/run/php-fpm.sock; ???????????fastcgi_index ?index.php; ???????????fastcgi_split_path_info ^(.+\.php)(.*)$; ???????????fastcgi_param PATH_INFO $fastcgi_path_info; ???????????fastcgi_param ?SCRIPT_FILENAME ?$document_root$fastcgi_script_name; ???????????include ???????fastcgi_params; ???????}

[Linux]PHP-FPM与NGINX的两种通讯方式

原文地址:https://www.cnblogs.com/yiyide266/p/9568749.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved