美文网首页
Nginx+uWSGI+Django问题汇总

Nginx+uWSGI+Django问题汇总

作者: 苏怡诞仁 | 来源:发表于2018-09-08 20:56 被阅读0次

    配置生产环境

    参考:http://doc.okbase.net/qq_38111600/archive/275608.html

    参考:https://blog.csdn.net/c465869935/article/details/53242126/


    可以参考的一个uWSGI配置样板

    [uwsgi]

    socket = 127.0.0.1:9001

    chdir=/media/root/kali/myproject/Ppython/django/mysite

    #chmod-socket=664

    master=true

    processes=2

    threads=2

    module=mysite.wsgi

    pidfile=/var/run/uwsgi.pid

    max-requests=5000

    uid=nginx

    gid=nginx

    #stats=127.0.0.1:9002

    vacuum=true

    daemonize = /var/log/nginx/uwsgi.log


    问题1

    python2和python3同时存在时,注意使用pip2、pip3来安装uwsgi时,容易造成/usr/bin/uwsgi文件被最后安装的版本覆盖,这样会使得版本混乱。

    问题2

    uwsgi.ini文件的配置内容应参考官网指导,因为配置文件的问题,曾出现过以下报错:16 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:9001", host: "localhost"

    配置Mysql时

    pip3 install mysqlclient 出现 OSError: mysql_config not found  或者 ModuleNotFoundError: No module named 'MySQLdb'

    apt-get install libmysqlclient-dev



    注意事项

    nginx.conf中应将动态请求交由uWSGI进程处理,二者端口对应

    对于静态请求,python3 manage.py collectstatic 可以将需要的静态文件移动至django.settings中定义的STATIC_ROOT目录

    相关文章

      网友评论

          本文标题:Nginx+uWSGI+Django问题汇总

          本文链接:https://www.haomeiwen.com/subject/afplgftx.html