Linux 部署 Django 系统
一:安装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.pid
daemonize=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-pcre
make && 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 进行访问即可
Linux 部署 Django 系统的更多相关文章
- Linux部署Django:报错 nohup: ignoring input and appending output to ‘nohup.out’
一.部署 Django 到远程 Linux 服务器 利用 xshell 通过 ssh 连接到 Linux服务器,常规的启动命令是 python3 manage.py runserver 但是,关闭 x ...
- linux ---部署django项目篇
uWSGI + nginx+ django + virtualenv + supervisor发布web服务器 项目部署步骤 1.项目准备阶段 1.准备项目代码,从本地拷贝 2.将项目上传到linux ...
- linux部署django项目流程(全)
1.python3和python2共存配置 流程在下面网址中 https://www.cnblogs.com/vinic-xxm/p/11358894.html 2.安装依赖包 yum install ...
- nginx + uwsgi 部署django项目
因项目需求,需要部署django项目,这里是基础的nginx配合uwsgi部署django,后续会采用docker部署的方式 环境: centos7 python3.5.4 django2.1.4 u ...
- [部署开发环境]部署django的生成环境nginx+uwsgi+django
#教程 # ubuntu部署django项目 # 部署准备 - ubuntu操作系统 -- vagrant虚拟 - Nginx服务器 -- 安装在ubuntu的web服务器 - uWSGI应用协议服务 ...
- Linux(CentOS7)系统中部署Django web框架
1. 概述 部署django和vue架在逻辑上可以分为web层与数据库层:web前端通过实现了WSGI协议的模块对python代码进行解析,而python代码中则通过特定于数据库的操作接口对数据库进行 ...
- 在裸机centos7系统中部署django项目的过程
概要 本文用一台安装了centos7.5系统的裸奔Linux机器(当然是虚拟机)详细讲解从无到有部署django项目的过程. 安装必要的工具 配置yum源 至于什么是yum源大家请自行百度,本人用的是 ...
- linux服务器批量部署应用系统shell脚本(Tomcat/jetty)
linux服务器批量部署应用系统shell脚本: 1.请更换代码内的服务器地址(Tomcat或jetty服务器) serverRoot=/home/undoner/java_tool/apache-t ...
- Python3.6+nginx+uwsgi部署Django程序到阿里云Ubuntu16.04系统
Python3.6+nginx+uwsgi部署Django程序到阿里云Ubuntu16.04系统 这个是写好的Django程序在本地机运行的情况,一个查询接口. 准备工作 1.首先购买一台阿里云的EC ...
随机推荐
- maven报错 java.lang.RuntimeException: com.google.inject.CreationException: Unable to create injector, see the following errors
2 errors java.lang.RuntimeException: com.google.inject.CreationException: Unable to create injector, ...
- js抽奖,跑马灯
分享自己写的跑马灯抽奖. HTML代码 <!--首先将一个div的背景设为一个圆形--> <div style=" width:240px; height:232px; b ...
- 阿里云-docker安装rabbitmq及无法访问主页
一.下载最新的rabbitmq docker pull rabbitmq 二.下载完以后启动容器 docker run -d -p 5672:5672 -p 15672:15672 --name my ...
- 解决Windows jmeter Non HTTP response message: Address already in use: connect 错误(转载)
jMeter报错: Response code: Non HTTP response code: java.net.BindExceptionResponse message: Non HTTP re ...
- No valid Maven installation found. Either set the home directory in the configuration dialog or set
原因: IDEA的maven地址设置出错,系统找不到指定的maven路径 解决: setting---->maven修改正确的maven链接地址. 设置你maven 的地址为你的存放路基就好了
- Hive中运行HQL语句错误
错误:org.apache.hadoop.yarn.exceptions.InvalidAuxServiceException( 或者为FAILED: Execution Error, return ...
- Java-DateUtils工具类
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; impor ...
- 【dmp文件还原到oralce数据库】
1.数据库执行语句,创建一个用户并赋予权限 --创建用户CREATE USER test2 IDENTIFIED BY 123456 DEFAULT TABLESPACE USERS TEMPORAR ...
- BZOJ 3926: [Zjoi2015]诸神眷顾的幻想乡(广义后缀自动机 多串)
因为任何一条路径都可以看做某两个叶子节点之间路径的一部分,然后分别把20个叶节点当作根,把整棵树看作trie树,那么一条路径就能看作是从根到某个点这一条路的后缀,构建SAM就能维护不同子串的个数了. ...
- 洛谷-P3805-Manacher模板
链接: https://www.luogu.org/problem/P3805 题意: 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 字符串长度为n 思路: ...