首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >centos怎么部署django?

centos怎么部署django?

提问于 2019-09-30 23:12:20
回答 0关注 0查看 302

请问centos怎么部署django项目,我部署后只能访问Welcome to nginx on Fedora!

但是访问不了项目

请问uwsgi和ngnix怎么配置?

代码语言:js
复制
ngnix.conf


#user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {

    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
	server_name 106.54.223.39;
	charset     utf-8;
	client_max_body_size 75M; 
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

#        location / {
#            root   html;
#            index  index.html index.htm;
#        }

	location / {
    uwsgi_pass 127.0.0.1:8000;
    include    /usr/local/nginx/conf/uwsgi_params;
    root "/root/project_res/pro_res";
}
	location /static {
    alias /root/project_res/pro_res/static;
    }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
         error_page   500 502 503 504  /50x.html;
         location = /50x.html {
             root   html;
         }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

代码语言:js
复制
uwsgi_conf.ini

[uwsgi]
# 使用nginx连接时使用,Django程序所在服务器地址
# 选择内网IP和端口
socket=127.0.0.1:8000

# 项目根目录
chdir=/root/project_res/pro_res

#项目中wsgi.py文件的相对目录
wsgi-file=pro_res/wsgi.py

# 进程数
processes=4

# 线程数
threads=40

# uwsgi服务器的角色
master=True

# 存放进程编号的文件
pidfile=uwsgi.pid

# 日志文件,因为uwsgi可以脱离终端在后台运行,日志看不见。以前的runserver是依赖终端的
daemonize=logs/uwsgi.log

# 指定虚拟环境所在目录,不能填相对目录
virtualenv=/usr/python/lib/python3.7/site-packages/pro_res_server

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档