微信抢票环境配置——nginx + uwsgi + django配置服务器
1 uwsgi配置
- 安装uwsgi
pip3 install uwsgi
- 配置django项目的uwsgi.ini,在WeChatTicket文件夹中新建uwsgi.ini文件
touch uwsgi.ini
vi uwsgi.ini
输入以下配置
[uwsgi]
# django项目监听的socket文件(可以使用端口代替)
socket = ./WeChatTicket.sock
# django项目所在目录
chdir = .
# django项目wsgi文件
wsgi-file = ./WeChatTicket/wsgi.py
master = true
processes = 2
threads = 4
vacuum = true
# 通过touch reload可以重启uwsgi服务器
touch-reload = ./reload
# 日志输出
daemonize = WeChatTicket.log
- 运行uwsgi服务器
uwsgi --ini uwsgi.ini
touch reload
2 http协议(80端口)下的nginx配置
- 安装nginx
sudo apt-get install nginx
cd /etc/nginx
- 修改nginx用户
vi nginx.conf
将第一行修改为
user root;
- 添加80端口的配置文件
cd conf.d
sudo touch WeChatTicket.conf
sudo vi WeChatTicket.conf
填入以下配置:
server{
listen 80;
server_name 服务器ip;
charset UTF-8;
client_max_body_size 75M;
location ~ ^/calculate {
// replace "path" to the path of your project
uwsgi_pass unix:///"path"/calculator/calculator.sock;
include /etc/nginx/uwsgi_params;
}
}
- 重启nginx服务器
sudo service nginx restart