Python 为django应用程序在nginx后面运行gunicorn

Python 为django应用程序在nginx后面运行gunicorn,python,django,nginx,gunicorn,Python,Django,Nginx,Gunicorn,我在/etc/nginx/sites enabled/nginx.conf cat /etc/nginx/sites-enabled/nginx.conf server { # Redirect all www.project.com requests to project.com listen 80; server_name www.******.co; return 301 http://*******.co$request_uri; } server {

我在
/etc/nginx/sites enabled/nginx.conf

cat /etc/nginx/sites-enabled/nginx.conf 
server {
    # Redirect all www.project.com requests to project.com
    listen 80;
    server_name www.******.co;
    return 301 http://*******.co$request_uri;
}

server {
    listen   80;
    server_name ******.co;
    location /admin/media/ {
        # this changes depending on your python version
        root /home/ubuntu/.virtualenvs/sos/lib/python2.7/site-packages/django/contrib;
    }
    location /static/admin {
        autoindex on;
        root  /home/ubuntu/.virtualenvs/sos/lib/python2.7/site-packages/django/contrib;
    }
    location /static/ {
        autoindex on;
    expires max;
        alias /home/ubuntu/codebase/static_files/;
    }
    location / {
    # This section is to redirect all http traffic to https if desired
    # if ($http_x_forwarded_proto != 'https') {
    #   rewrite ^ https://$host$request_uri? permanent;
    # }

        client_max_body_size 5M;
        client_body_buffer_size 128k;
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 300;
        proxy_read_timeout 300;
        proxy_pass http://127.0.0.1:8000/;
    }
    # what to serve if upstream is not available or crashes
    error_page 500 502 503 504 /home/ubuntu/codebase/static_files/500.html;
}
我已经通过
pip install gunicorn
安装了
gunicorn
,并将其放入django设置“*已安装的应用程序*

如前所述,我运行python manage.py run_gunicorn,它不会给出任何错误,但当我打开我的站点时,我得到

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
我确信gunicorn正在运行是因为以下原因-

ps aux| grep gunicorn

ubuntu    1819  0.0  0.4 121928 16944 ?        S    22:08   0:00 python manage.py run_gunicorn -D
ubuntu    1822  0.0  0.7 136264 29556 ?        S    22:08   0:00 python manage.py run_gunicorn -D
ubuntu    2017  0.0  0.0   8172   944 pts/3    S+   22:31   0:00 grep --color=auto gunicorn

你知道怎么回事吗?在过去的8个小时里,我一直在磕头

您是否有机会启用/默认/etc/nginx/站点?也许你写的太多了你让我成为了我的白痴。。。1000票赞成上述评论