php-fpm nginx配置文件 处理 Permission denied 错误

配置php-fpm脚本(php-fpm.conf):

[www]
    131 
    132 ; Per pool prefix
    133 ; It only applies on the following directives:
    134 ; - 'access.log'
    135 ; - 'slowlog'
    136 ; - 'listen' (unixsocket)
    137 ; - 'chroot'
    138 ; - 'chdir'
    139 ; - 'php_values'
    140 ; - 'php_admin_values'
    141 ; When not set, the global prefix (or /usr/local/php) applies instead.
    142 ; Note: This directive can also be relative to the global prefix.
    143 ; Default Value: none
    144 ;prefix = /path/to/pools/$pool
    145 
    146 ; Unix user/group of processes
    147 ; Note: The user is mandatory. If the group is not set, the default user's group
    148 ;       will be used.
    149 user = dyh
    150 group = dyh
    151 
    152 ; The address on which to accept FastCGI requests.
    153 ; Valid syntaxes are:
    154 ;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
    155 ;                            a specific port;
    156 ;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
    157 ;                            a specific port;
    158 ;   'port'                 - to listen on a TCP socket to all IPv4 addresses on a
    159 ;                            specific port;
    160 ;   '[::]:port'            - to listen on a TCP socket to all addresses
    161 ;                            (IPv6 and IPv4-mapped) on a specific port;
    162 ;   '/path/to/unix/socket' - to listen on a unix socket.
    163 ; Note: This value is mandatory.
    164 listen = /tmp/php-fpm.sock
    165 ;listen = 127.0.0.1:9000
    166 
    167 ; Set listen(2) backlog.
    168 ; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
    169 ;listen.backlog = 65535
    170 
    171 ; Set permissions for unix socket, if one is used. In Linux, read/write
    172 ; permissions must be set in order to allow connections from a web server. Many
    173 ; BSD-derived systems allow connections regardless of permissions.
    174 ; Default Values: user and group are set as the running user
    175 ;                 mode is set to 0660
    176 ;listen.owner = www
    177 ;listen.group = www
    178 listen.mode = 0666


当此处listen配置成unix socket时,在nginx中也需配置成相同的配置

配置为unix socket时需将 listen.mode = 0666 避免在使用nginx时出现 (connect() to unix:/tmp/php-fpm.sock failed (13: Permission denied))错误

nginx中fast cgi配置可用如下:

     13     location ~ \.php$ {
     14 #        fastcgi_pass 127.0.0.1:9000;
     15         fastcgi_pass unix:/tmp/php-fpm.sock;
     16         fastcgi_index index.php;
     17         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     18         include        fastcgi_params;
     19     }

其中fastcgi_pass 需要与 php-fpm.conf中一致

配置完成后去php目录启动 php-fpm,nginx中启动nginx.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值