我想在带有centOS 7的服务器中部署我的烧瓶服务 . 所以我遵循了本教程 - https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-centos-7 .
运行 systemctl start nginx
命令后,我收到此错误:
nginx: [emerg] bind() to 0.0.0.0:5000 failed (13: Permission denied)
我的 nginx.conf
档案:
server {
listen 5000;
server_name _;
location / {
include uwsgi_params;
uwsgi_pass unix:/root/fiproxy/fiproxyproject/fiproxy.sock;
}
}
Note: 烧瓶服务和wsgi工作正常 . 我试图用超级用户运行nginx,错误仍然存在 .
2 回答
Nginx master process 需要root权限 . 因为它需要绑定端口 .
您需要在root用户下启动Nginx .
然后,您可以在 nginx.conf 中定义子进程的用户 .
在互联网上搜索了很多,我找到了解决问题的方法 .
我运行此命令以获取我的机器中所有使用过的端口:
semanage port -l
. 之后,我用以下内容过滤了输出:semanage port -l | grep 5000
.我意识到这个端口5000是
commplex_main_port_t
使用的,我在speedguide中搜索过,我发现:5000 tcp,udp **UPnP**
.结论,也许我的问题是绑定一个标准端口 .
要添加所需的端口,请使用以下命令:
现在用sudo运行nginx: