如果fastcgi采用socket配置,权限如何设置
来源:3-30 Fastcgi代理配置演示及测试

慕村1342571
2021-08-05
我的nginx和PHP是装在同一台服务器,这里如果要配置socket方式该如何操作呢,环境如下
1、php-fpm的socket文件:
/var/opt/remi/php74/run/php-fpm/www.sock
2、nginx的虚拟服务站点的配置如下
server {
listen 80;
server_name 阿里申请的域名;
access_log /var/log/nginx/audio.access.log main;
root /opt/app/audio;
location / {
index index.php;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass unix:/var/opt/remi/php74/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#location / {
# root /opt/app/audio;
# index index.html index.htm;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 404 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
3、跟踪/var/log/nginx/error.log 得到如下结果
2021/08/05 16:22:28 [crit] 15288#15288: *4 connect() to unix:/var/opt/remi/php74/run/php-fpm/www.sock failed (13: Permission denied) while connecting to upstream, client
权限被限制,将/var/opt/remi/php74/run/php-fpm/www.sock 文件的组权限和用户权限都修改为nginx还是报权限错误
这个问题可以怎么解决
1回答
-
Jeson
2021-08-09
关闭SeLinux试试
1.临时关闭(不用重启机器):
setenforce 0 ##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
2.修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可
2.执行下面的命令
setsebool -P httpd_can_network_connect 1
00
相似问题