Nginx

1.服务器
2.Ip
3.代码上传
4.python环境和相关模块
5.启动runserver

1、通过命令启动
django的socket server较差,用uwsgi(python的模块)

uwsgi --http 192.168.0.101:8080 --file teacher/wsgi.py --static-map=/static=static


file:设置启动web server,不设置用默认的web server
static :映射,指定静态文件

2、通过配置文件启动
创建一个uwsgi.ini
#项目目录
chdir=/opt/project_teacher/teacher/
# 指定项目的application
module = teacher.wsgi:application
# 指定sock的文件路径
socket = /opt/project_teacher/script/uwsgi.socket
# 进程个数
workers=5
pidfile=/opt/project_teacher/script/uwsgi.pid
# 指定ip端口
http=192.168.80.128:8080
# 指定静态文件
static-map=/static=/opt/project_teacher/static/

#启动uwsgi的用户名和用户组
uid=root
gid=root


常用命令:
启动uwsgi --ini uwsgi.ini
停止uwsgi --stop uwsgi.pid
重载uwsgi --reload uwsgi.ini

uwsgi缺陷
静态请求较差,用nginx

nginx
1.安装
配置文件
name
baseurl=

server {
listen 80;
server name www.;
access_log /xxx/;#Nginx日志配置
Charset utf-8;
gzip on; #启用压缩,提高速度
error_page 404 /404.html;
error_page 500 502 503 /50x.html;
location / {
include uwsgi_params; #导入模块
uwsgi_connet_timeout 30;
uwsgi_pass unix:/opt/project_teacher/script/uwsgi.sock; # 传动态请求
}
location /static/ {
alias /opt/project_teacher/teacher/static/;
index index.html;
}
}









 

posted @ 2018-08-17 16:21  心平万物顺  阅读(94)  评论(0编辑  收藏  举报