【问题标题】:why nginx not starting my service?为什么 nginx 不启动我的服务?
【发布时间】:2014-07-17 13:39:38
【问题描述】:

我正在使用 linux fedora,我将 nginx 安装为 sudo yum install nginx。我创建了一个 django 项目并将端口分配为 guicorn projectname.wsgi:application --bind=127.0.0.1:8001。我在 /etc/nginx/sites-enabled/default 中创建了一个文件

在我的default 文件中,我有以下代码:

server {
   listen localhost:8006;

   location / {
   proxy_pass http://127.0.0.1:8001;
   }

   location /static/ {
   autoindex on;
   alias /home/user/Desktop/projects/28-05-2014/HMS/static/;
}
}

当我将我的 nginx 服务器主页检查为 localhost:80 时,它正在运行。但是当我调用 localhost:8006 时,它没有连接。当我检查与netstat -lnt | grep 80 的活动连接时,我发现只有 nginx 默认服务正在运行。我在做什么错误。任何帮助都会得到帮助

【问题讨论】:

  • 你重新加载nginx了吗?
  • @AlexeyTen,是的,我已经重启了很多次

标签: python django nginx gunicorn


【解决方案1】:

把上面的代码放在/etc/nginx/nginx.conf文件中,那么你的配置文件如下所示

nginx.conf

server {
   listen localhost:8006;

   location / {
   proxy_pass http://127.0.0.1:8001;
   }

   location /static/ {
   autoindex on;
   alias /home/user/Desktop/projects/28-05-2014/HMS/static/;
}
}

【讨论】:

    【解决方案2】:

    没有足够的信息来回答。

    启用日志记录:

    access_log /var/log/nginx/example.access.log;
    error_log /var/log/nginx/example.error.log;
    

    并查看日志文件的内容。如果您无法弄清楚,请在此处发布日志输出。问题没有提供足够的数据。当你更新你的问题时,我会更新这个答案。

    【讨论】:

    • 修改后的文件重启了服务器并给出了请求但没有任何反应。甚至文件也没有创建。第一台服务器没有列出任何写入日志文件的请求
    • 您似乎有权限问题。按照这个:stackoverflow.com/questions/18714902/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多