欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP-FPM无法生成.sock文件

程序员文章站 2022-05-20 21:19:40
...
centos7 上 yum 安装 php 5.6
vim /etc/php-fpm.d/www.conf

修改

;listen = 127.0.0.1:9000
listen=/dev/shm/php-fcgi.sock

创建php-fcgi.sock文件

touch listen=/dev/shm/php-fcgi.sock
chmod 777 /dev/shm/php-fcgi.sock

重启php-fpm

systemctl restart php-fpm

但是/dev/shm/php-fcgi.sock还是普通文件 ,不是socket文件,查看 log 没报错,如何解决?

回复内容:

centos7 上 yum 安装 php 5.6

vim /etc/php-fpm.d/www.conf

修改

;listen = 127.0.0.1:9000
listen=/dev/shm/php-fcgi.sock

创建php-fcgi.sock文件

touch listen=/dev/shm/php-fcgi.sock
chmod 777 /dev/shm/php-fcgi.sock

重启php-fpm

systemctl restart php-fpm

但是/dev/shm/php-fcgi.sock还是普通文件 ,不是socket文件,查看 log 没报错,如何解决?

删除普通文件,以Unix Socket方式运行时,sock文件由php-fpm创建

配置文件不是写着了么,php-fpm会自己生成这个socket文件,并且被master进程所引用

; 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 IPv4 addresses 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.

我感觉是配置写错了。

php-fpm.conf

listen = /dev/shm/php-fcgi.sock
listen.owner = www
listen.group = www
listen.mode = 0660

nginx.conf

fastcgi_pass unix:/dev/shm/php-fcgi.sock;
相关标签: php