博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux 部署 Django 系统
阅读量:4319 次
发布时间:2019-06-06

本文共 3417 字,大约阅读时间需要 11 分钟。

一:安装uwsgi

  pip3 install uwsgi

二:进入项目目录下,创建uwsgi.ini配置文件

[uwsgi]# 使用nginx连接时使用功能,上线时才使用socket,指定项目执行的端口号socket=127.0.0.1:8000# 项目目录chdir=/data/webapp/otp_manage# 项目中wsgi.py文件的目录,相对于项目目录wsgi-file=otp_manage/wsgi.py# 最大进程workers=3# 开启主进程master=True# 退出、重启时清理文件vacuum = true#pidfile=uwsgi.piddaemonize=uwsgi.log  

三:启动服务

uwsgi在哪个目录启动,就会在哪个目录生成uwsgi.pid和uswgi.log文件,故需要切换到项目目录下执行

启动:uwsgi --ini uwsgi.ini
停止:uwsgi --stop uwsgi.pid
重启:uwsgi --reload uwsgi.pid
强制停止:killall -8 uwsgi
这里我们启动uwsgi服务,可以通过ps -ef | grep uwsgi看到已经有四个uwsgi服务启动。

 

四:安装Nginx

tar zxf nginx-1.8.1.tar.gz cd nginx-1.8.1./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcremake && make install  

五编写nginx.conf配置文件

user www www;worker_processes 2;error_log /usr/local/nginx/logs/nginx_error.log notice;pid /usr/local/nginx/sbin/nginx.pid;worker_rlimit_nofile 204800;events        {        use epoll;        worker_connections 204800;        }http        {        include mime.types;        default_type  application/octet-stream;        charset utf-8;        server_tokens off;        server_names_hash_bucket_size 512;        client_header_buffer_size 512k;        large_client_header_buffers 64 512k;        client_max_body_size 100m;        proxy_ignore_client_abort on;        sendfile on;        tcp_nopush on;        keepalive_timeout 120;        keepalive_requests 1024;        fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2 keys_zone=TEST:10m inactive=30d max_size=3096m;        fastcgi_connect_timeout 300;        fastcgi_send_timeout 300;        fastcgi_read_timeout 300;        fastcgi_buffer_size 4k;        fastcgi_buffers 8 4k;        fastcgi_busy_buffers_size 8k;        fastcgi_temp_file_write_size 8k;#       fastcgi_cache TEST;        fastcgi_cache_valid 200 302 1h;        fastcgi_cache_valid 301 1d;        fastcgi_cache_valid any 1m;        fastcgi_cache_min_uses 1;        fastcgi_cache_use_stale error timeout invalid_header http_500;        open_file_cache max=204800 inactive=20s;        open_file_cache_min_uses 1;        open_file_cache_valid 60s;        tcp_nodelay on;        gzip on;        gzip_min_length 1k;        gzip_buffers 16 64k;        gzip_http_version 1.1;        gzip_comp_level 6;        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;        gzip_vary on;        log_format access '$remote_addr - $remote_user [$time_local] "$request" '                         '"$status" $body_bytes_sent "$http_referer" '                         '"$http_user_agent" "$http_x_forwarded_for" '                         '"$upstream_addr" "$upstream_status" "$request_time" "$upstream_response_time" $bytes_sent $request_length';include  /usr/local/nginx/conf/vhosts/*.conf;}  

六:创建vhosts目录。编写.conf文件

server {        listen       80;        server_name  localhost;        location / {            include  uwsgi_params;            uwsgi_pass  127.0.0.1:8000;            uwsgi_param UWSGI_SCRIPT otp_manage.wsgi;            # /data/webapp/otp_manage 是项目目录            uwsgi_param UWSGI_CHDIR /data/webapp/otp_manage;            index  index.html index.htm;            client_max_body_size 35m;        }      location /static {          client_max_body_size 35m;          alias /data/webapp/otp_manage/statics;      }    }  

启动Nginx  进行访问即可

转载于:https://www.cnblogs.com/happlyp/p/10899755.html

你可能感兴趣的文章
面试题5:字符串替换空格
查看>>
[Codevs] 线段树练习5
查看>>
Amazon
查看>>
component-based scene model
查看>>
Echart输出图形
查看>>
hMailServer搭建简单邮件系统
查看>>
从零开始学习jQuery
查看>>
Spring+SpringMVC+MyBatis深入学习及搭建(四)——MyBatis输入映射与输出映射
查看>>
opacity半透明兼容ie8。。。。ie8半透明
查看>>
CDOJ_24 八球胜负
查看>>
Alpha 冲刺 (7/10)
查看>>
一款jQuery打造的具有多功能切换的幻灯片特效
查看>>
SNMP从入门到开发:进阶篇
查看>>
@ServletComponentScan ,@ComponentScan,@Configuration 解析
查看>>
unity3d 射弹基础案例代码分析
查看>>
thinksns 分页数据
查看>>
os模块
查看>>
LINQ to SQL vs. NHibernate
查看>>
基于Angular5和WebAPI的增删改查(一)
查看>>
windows 10 & Office 2016 安装
查看>>