nginx不提供公共服务器上的静态文件

时间:2016-02-03 12:54:31

标签: django nginx

我正在尝试使用nginx和gunicorn部署django项目。我按照this教程。
Gunicorn能够运行我的项目,但nginx不提供静态文件。

我的nginx conf:

server {
    listen 80;
    server_name 69.12.74.39;
    location / {
        proxy_pass http://0.0.0.0:8001;
    }

    location /static/ {
      autoindex on;
      alias /home/ekodev/accounts/arham/ekomerz/static/;
    }
}

我检查了静态文件夹的位置及其右侧。我使用的gunicorn命令是:

gunicorn ekomerz.wsgi:application --bind=0.0.0.0:8001

编辑:在我的本地机器上运行正常。

server {
    listen localhost:8000;

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

    location /static/ {
        autoindex on;
        alias /home/manish/Desktop/ekomerz/ekomerz/static/;
    }
}

配置有什么问题?

1 个答案:

答案 0 :(得分:-1)

您的端口80上运行Apache,nginx无法绑定到端口80。 查看您的日志文件。

您可以使用:sudo service apache2 stop

停止apache

使用:sudo service nginx start

启动nginx