Django + Uwsgi + Nginx 的生产环境部署

Django + Uwsgi + Nginx 的生产环境部署

参考网址:
https://www.cnblogs.com/chenice/p/6921727.html
http://wuchengyi.com/post/1/

Nginx 安装配置
参考网址:http://www.runoob.com/linux/nginx-install-setup.html

Centos下安装nginx步骤解析
参考网址:https://www.cnblogs.com/angellating/p/6479876.html

出现错误:(注意:查看日志文件)
参考网址:https://blog.csdn.net/LY_Dengle/article/details/69568652

uwsgi.ini (注意:http=0.0.0.0:8080 的端口不能和nginx:80的端口冲突)

1[uwsgi] 2# 项目目录 3chdir=/root/myproject/ 4 5# 指定项目的application 6module=myproject.wsgi:application 7# 指定sock的文件路径 8socket=127.0.0.1:8000 9# 进程个数 10workers=5 11pidfile=/root/myproject/script/uwsgi.pid 12# 指定IP端口 13http=0.0.0.0:8080 14# 指定静态文件 15static-map=/static=/root/myproject/static 16# 启动uwsgi的用户名和用户组 17uid=root 18gid=root 19# 启用主进程 20master=true 21# 自动移除unix Socket和pid文件当服务停止的时候 22vacuum=true 23# 序列化接受的内容,如果可能的话 24thunder-lock=true 25# 启用线程 26enable-threads=true 27# 设置自中断时间 28harakiri=30 29# 设置缓冲 30post-buffering=4096 31# 设置日志目录 32daemonize=/root/myproject/script/uwsgi.log

/usr/loacl/nginx/conf:nginx.conf

1user www www; 2worker_processes 2; #设置值和CPU核心数一致 3error_log /usr/local/nginx/logs/nginx_error.log crit; #日志位置和日志级别 4pid /usr/local/nginx/nginx.pid; 5#Specifies the value for maximum file descriptors that can be opened by this process. 6worker_rlimit_nofile 65535; 7events 8{ 9 use epoll; 10 worker_connections 65535; 11} 12http 13{ 14 include mime.types; 15 default_type application/octet-stream; 16 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 17 '$status $body_bytes_sent "$http_referer" ' 18 '"$http_user_agent" $http_x_forwarded_for'; 19 20#charset gb2312; 21 22 server_names_hash_bucket_size 128; 23 client_header_buffer_size 32k; 24 large_client_header_buffers 4 32k; 25 client_max_body_size 8m; 26 27 sendfile on; 28 tcp_nopush on; 29 keepalive_timeout 60; 30 tcp_nodelay on; 31 fastcgi_connect_timeout 300; 32 fastcgi_send_timeout 300; 33 fastcgi_read_timeout 300; 34 fastcgi_buffer_size 64k; 35 fastcgi_buffers 4 64k; 36 fastcgi_busy_buffers_size 128k; 37 fastcgi_temp_file_write_size 128k; 38 gzip on; 39 gzip_min_length 1k; 40 gzip_buffers 4 16k; 41 gzip_http_version 1.0; 42 gzip_comp_level 2; 43 gzip_types text/plain application/x-javascript text/css application/xml; 44 gzip_vary on; 45 46 #limit_zone crawler $binary_remote_addr 10m; 47 #下面是server虚拟主机的配置 48 server { 49 listen 80; 50 server_name 监听端口; 51 charset UTF-8; 52 access_log /var/log/nginx/myweb_access.log; 53 error_log /var/log/nginx/myweb_error.log; 54 55 client_max_body_size 75M; 56 57 location / { 58 include uwsgi_params; 59 uwsgi_pass 127.0.0.1:8000; # 和uwsgi的socket配置保持一致 60 uwsgi_read_timeout 2; 61 } 62 location /static { 63 expires 30d; 64 autoindex on; 65 add_header Cache-Control private; 66 alias /root/myproject/static/; # 关联项目静态文件 67 } 68 } 69}
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )