我已经安装了nginx version: nginx/1.19.1
,PHP 7.4.8 (fpm-fcgi)
和PHP 7.4.8 (cli)
。
我的Nginx服务器-块配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name x.x.x.x;
location / {
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
我测试了http://x.x.x.x/info.php,它给了我错误
Nginx日志错误:
2020/07/30 10:30:10 [crit] 24996#24996: *1 connect() to unix:/var/run/php/php7.2-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 37.111.128.199, server: 54.175.13.25, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "54.175.13.25"
给我权限被拒绝的错误,因此 为什么会这样?
答案 0 :(得分:1)
我目前无法发表评论,因此我将其作为答案。
您所做的是一种方法。
另一种方法是在/etc/php/7.4/fpm/pool.d/www.conf
中更改用户:
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
就个人而言,我更愿意为php-fpm更改用户,而不是为nginx更改用户。
干杯。
答案 1 :(得分:0)
花很多时间解决问题
我通过将etc / nginx / nginx.conf {user nginx}更改为{user www-data}其实际权限问题,然后保存并重新启动nginx(sudo systemctl restart nginx)来解决。
import wx
class Frame(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None, title=title, size=(350,200))
app = wx.App(redirect=True)
top = Frame("Hello World")
top.Show()
app.MainLoop()