django用uwsgi和nginx部署失败的问题

BrankoJuan 发布于 2016/05/18 20:15
阅读 530
收藏 1

我自己尝试不是django+uwsgi+nginx,发现部署失败,访问80端口出来的还是nginx默认的页面

版本信息:

nginx version: nginx/1.0.15

Python 2.7.11

django:(1, 9, 5, 'final', 0)

uwsgi:2.0.13.1

部署方式:

1)创建django工程和app: django-admin startproject apptest, python manage.py startapp app1;

2) 配置uwsgi,uwsgi --http :8000 --module apptest.wsgi;运行命令后,另一台机器可以通过ip+端口号的方式访问页面,出来的django的页面

3)配置nginx,修改/etc/nginx/nginx.conf,在默认文件的基础上加了server字段,结果如下:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    
    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;

    server {
        listen 80;
        server_name 192.168.67.152;
        access_log /home/access.log;
        error_log /home/error.log;
        location / {
            uwsgi_pass 127.0.0.1:8630;
            include uwsgi_params;
        } 
    }
}

uwsgi_params文件如下:

uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;



4)以socket的方式重新启动uwsgi,uwsgi --socket :8630 --module apptest.wsgi

5)重启nginx,/etc/init.d/nginx restart

6)但是访问地址+80端口号,出现的还是nginx默认的页面,不是应该是django的默认页面吗?说明我没有配置成功,哪里有问题,哪个高手帮忙看一下






加载中
0
B
BrankoJuan
已经知道原因啦,是因为conf文件配置的问题,需要将server加载conf.d的文件中
返回顶部
顶部