部署工资单系统

 Django + uwsgi + nginx + virtualenv

uwsgi.ini配置

[uwsgi]
#使用nginx连接时使用,Django程序所在服务器地址
socket=0.0.0.0:10001
#直接做web服务器使用,Django程序所在服务器地址
;http=0.0.0.0:10001
#项目目录
chdir=/opt/payslip
#项目中wsgi.py文件的目录,相对于项目目录
wsgi-file=payslip/wsgi.py
# 进程数
processes=2
# 线程数
threads=2
# uwsgi服务器的角色
master=True
# 存放进程编号的文件
pidfile=uwsgi.pid
# 日志文件,因为uwsgi可以脱离终端在后台运行,日志看不见。我们以前的runserver是依赖终端的
daemonize=uwsgi.log
# 指定依赖的虚拟环境
virtualenv=/home/shion/.virtualenvs/payslip

Nginx配置:

 1 server {
 2     listen 10000;
 3     listen [::]:10000 default_server;
 4 
 5 
 6     root /var/www/html;
 7 
 8     # Add index.php to the list if you are using PHP
 9     index index.html index.htm index.nginx-debian.html;
10 
11     server_name localhost.com;
12 
13     location / {
14         # First attempt to serve request as file, then
15         # as directory, then fall back to displaying a 404.
16         include /etc/nginx/uwsgi_params;
17         uwsgi_pass 0.0.0.0:10001;
18         root html;
19         index index.html index.htm;
20     }
21     location /static {
22         alias /opt/payslip/static;
23         
24     }
Nginx.conf

注意事项

  1、uwsgi里面配置的端口号 和 nginx反向代理的端口不能一直,不然会导致uwsgi无法启动

  2、 virtualenv环境应该是python3 环境, 之前没注意导致查了很久的问题  

mkvirtualenv -p /usr/bin/python3.6 payslip

nginx相关命令

nginx -s reload  平滑重启
nginx -s stop  停止nginx
nginx  启动nginx

猜你喜欢

转载自www.cnblogs.com/echo2019/p/11867813.html