nginx部署django的配置
nginx 文件权限问题
chcon -Rt httpd_sys_content_t /home/szw/data/server/ai_shop/dist_h5/
nginx 文件权限问题
setsebool -P httpd_can_network_connect 1
/usr/bin/nohup python3 manage.py runserver 0.0.0.0:9644 > system.log 2>&1 &
nginx
server { listen 80; server_name 192.168.1.169; access_log /var/log/nginx/access.log main; charset utf-8; gzip on; gzip_comp_level 6; gzip_vary on; gzip_min_length 1000; gzip_proxied any; gzip_buffers 16 8k; # gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php application/json text/json image/jpeg image/gif image/png application/octet-stream; error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location / { # try_files $uri /index.html; include uwsgi_params; uwsgi_connect_timeout 30; # uwsgi_pass unix:/www/script/uwsgi.sock; uwsgi_pass unix:/www/script/uwsgi.sock; } location /static/ { alias /www/WisdomPoliceStationManageChana/static/; index index.html index.htm; } location /Upload/ { alias /www/WisdomPoliceStationManageChana/Upload/; index index.html index.htm; } }
uwsgi
# uwsig使用配置文件启动 [uwsgi] # 项目目录 chdir=/www/WisdomPoliceStationManageChana/ # 指定项目的application module=WisdomPoliceStationManageChana.wsgi:application # 指定sock的文件路径 socket=/www/script/uwsgi.sock # 进程个数 workers=5 pidfile=/www/script/uwsgi.pid # 指定IP端口 http=127.0.0.1:8001 # 指定静态文件 static-map=/static=/www/WisdomPoliceStationManageChana/static # 启动uwsgi的用户名和用户组 uid=root gid=root # 启用主进程 master=true # 自动移除unix Socket和pid文件当服务停止的时候 vacuum=true # 序列化接受的内容,如果可能的话 thunder-lock=true # 启用线程 enable-threads=true # 设置自中断时间 harakiri=30 # 设置缓冲 post-buffering=4096 # 设置日志目录 daemonize=/www/script/uwsgi.log
# app未启动成功那么uwsgi也不启动
need-app=true
nginx重定向
location / { proxy_pass http://127.0.0.1:9000/; #proxy_pass http://111.74.20.227/:9000/; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }

浙公网安备 33010602011771号