• 部署工资单系统


     Django + uwsgi + nginx + virtualenv

    setting静态文件配置

    STATIC_URL = '/static/'
    STATICFILES_DIRS = [
        os.path.join(BASE_DIR, "statics"),
    ]
    STATIC_ROOT = '/opt/production/production/static'

    收集静态文件

    python manage.py  collectstatic

    改中文,还上海时区

    LANGUAGE_CODE = 'zh-hans'
    
    TIME_ZONE = 'Asia/Shanghai'

    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
  • 相关阅读:
    【BZOJ4198】[Noi2015]荷马史诗 贪心+堆
    【BZOJ4200】[Noi2015]小园丁与老司机 DP+最小流
    【BZOJ2839】集合计数 组合数+容斥
    【BZOJ2989】数列 kd-tree
    【BZOJ4240】有趣的家庭菜园 树状数组+贪心
    【BZOJ4238】电压 DFS树
    【BZOJ4237】稻草人 cdq分治+单调栈+二分
    Python Web学习笔记之WebSocket原理说明
    Python Web学习笔记之Cookie,Session,Token区别
    Python Web学习笔记之图解TCP/IP协议和浅析算法
  • 原文地址:https://www.cnblogs.com/echo2019/p/11867813.html
Copyright © 2020-2023  润新知