Django nginx部署

配置环境

安装Python3
1、安装gcc,用于编译Python源码
yum install gcc
2、下载源码包,https://www.python.org/ftp/python/
3、解压并进入源码文件
4、编译安装
./configure
make all
make install
模式:/usr/local/bin/python3

 安装Django

 

1
pip3 install django==1.11.7

如果报错:no module _sqlite3
  yum install sqlite-devel

 

 

 

 

 

nginx

安装

1
yum install nginx

配置

user root;
                    worker_processes 4;

                    error_log /var/log/nginx/error.log;
                    pid /var/run/nginx.pid;

                    events {
                        worker_connections  1024;
                    }


                    http {
                        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;
                        tcp_nodelay         on;
                        keepalive_timeout   65;

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

                        upstream django {
                            server 127.0.0.1:8001; 
                        }
                        server {
                            listen      80;

                            charset     utf-8;

                            # max upload size
                            client_max_body_size 75M;

                            location /static {
                                alias  /data/s9deploy/allstatic; 
                            }

                            location / {
                                uwsgi_pass  django;
                                include     uwsgi_params;
                            }
                        }
                    }

 

 

 

uwsgi


1
pip3 install uwsgi







 
 
posted @ 2017-12-19 16:33  排骨南  阅读(151)  评论(0编辑  收藏  举报