博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Linux]PHP-FPM与NGINX的两种通讯方式
阅读量:5206 次
发布时间:2019-06-14

本文共 2770 字,大约阅读时间需要 9 分钟。

一、通过监听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进程间通讯

通过配置php-fpm.d/www.conf Listen 项,php-fpm主进程启动时会在这个目录创建一个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;        }

 

转载于:https://www.cnblogs.com/yiyide266/p/9568749.html

你可能感兴趣的文章
MongoDB一些基本的命令
查看>>
尚未为数据源“RptDataSet_StatEC”提供数据源实例
查看>>
POJ 1410 Intersection
查看>>
Linux服务部署:nginx服务 nfs服务
查看>>
Spring Boot热部署(springloader)
查看>>
我要写一篇动态计算tableView-cell高度的随笔
查看>>
2.2 数据库高速缓冲区
查看>>
0课1-2节——刚接触开发板之接口接线工具
查看>>
分治法求解最大子段和问题
查看>>
H5实现formdata+ajax+上传进度上传文件
查看>>
iOS 6 编程 - 自动布局(Auto Layout)系列文章
查看>>
一. python的collections模块
查看>>
Linux之路(原发表于07年,现在搬到博客)
查看>>
Varnish
查看>>
20155338 《JAVA程序设计》实验五网络编程与安全实验报告
查看>>
查看Weblogic JNDI 树的几种方式
查看>>
组件之间的通信(持续补充)
查看>>
Objective-C基础教程学习笔记(七)Xcode快捷健
查看>>
Ubuntu下的UNITY和GNOME界面
查看>>
SVN备份及其还原 — dump/load方法
查看>>