Python/Go

uwsgi 配置

2018-01-25  本文已影响6628人  _琳哥

先贴个官方文档
安装python , 及虚拟环境, django 等
还要安装uwsgi

pip install uwsgi

现在先贴下现有项目目录结构


project.png

现在因为wsgi.py已经有django给生成了 .
我们只需要在项目目录, 即manage.py的同级目录创建文件myweb_uwsgi.ini


image.png
[uwsgi]
# Django-related settings

socket = 192.16864.131.:8000

# the base directory (full path)
chdir           = /home/lin/Desktop/lin/code/workspace/partner


# Django s wsgi file
module          = partner.wsgi:application
# wsgi-file = myproject/wsgi.py

# process-related settings
# master
master          = true

# maximum number of worker processes
processes       = 4

# ... with appropriate permissions - may be needed
# chmod-socket    = 664
# clear environment on exit
vacuum          = true

daemonize       = /home/lin/Desktop/lin/code/workspace/partner/uwsgi_log.log
 
pidfile = /home/lin/Desktop/lin/code/workspace/partner/uwsgi_pid.log
image.png
 Can't find section "uwsgi" in INI configuration file myweb_uwsgi.ini

文件里面的字段意思:

配完就能运行起uwsgi了

uwsgi --ini myweb_uwsgi.ini 

最后贴一下nginx的配置了.

server {
    listen         8099;
    server_name    192.168.64.131
    charset UTF-8;
    access_log      /var/log/nginx/myweb_access.log;
    error_log       /var/log/nginx/myweb_error.log;

    client_max_body_size 75M;

    location / {
        include uwsgi_params;
        uwsgi_pass 192.168.64.131:8000;
        uwsgi_read_timeout 20;
    }
    location /static {
        expires 30d;
        autoindex on;
        add_header Cache-Control private;
        alias /home/lin/Desktop/lin/code/workspace/partner/static;
     }
 }

上一篇 下一篇

猜你喜欢

热点阅读