Nginx权限被拒绝

时间:2015-10-09 17:55:26

标签: nginx flask

我想在带有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;
        }
    }

注意:刻录服务和wsgi工作正常。我试图用超级用户运行nginx,错误仍然存​​在。

2 个答案:

答案 0 :(得分:1)

Nginx 主进程需要root权限。因为它需要绑定端口 你需要在root用户下启动Nginx 然后,您可以在 nginx.conf 中定义子进程的用户。

答案 1 :(得分:1)

在互联网上搜索了很多,我找到了解决问题的方法。

我运行此命令以获取我的计算机中所有已使用的端口:semanage port -l。 之后,我使用:semanage port -l | grep 5000过滤了输出。

我意识到commplex_main_port_t使用了这个端口5000,我在speedguide中搜索过,我发现:5000 tcp,udp **UPnP**

结论,也许我的问题是绑定一个标准端口。

要添加所需的端口,请使用以下命令:

sudo semanage port -a -t http_port_t  -p tcp [yourport]

现在使用sudo运行nginx:

sudo systemctl stop nginx
sudo systemctl start nginx