推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
ffx0s
V2EX  ›  Python

django+uwsgi+nginx 出现问题

  •  
  •   ffx0s · Feb 20, 2015 · 13376 views
    This topic created in 4273 days ago, the information mentioned may be changed or developed.

    web页面出现Internal Server Error,查看错误日志提示: 2015/02/18 19:51:12 [error] 810#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server: xx.xx.xx.xx, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8000", host: "xx.xx.xx.xx"。求解所方法。

    31 replies  •  2015-04-03 00:23:05 +08:00
    dingyaguang117
    dingyaguang117
    Feb 20, 2015
    1
    uwsgi配置贴一下
    surefire
    surefire
    Feb 20, 2015
    2
    8000端口没开吧
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    3
    @surefire 开了。
    tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    4
    server {

    listen 80;
    server_name 121.40.90.156;
    access_log /mydata/www/log/access.log;
    error_log /mydata/www/log/error.log;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
    root /mydata/www;
    include uwsgi_params;
    # uwsgi_pass 127.0.0.1:9090;
    uwsgi_pass 127.0.0.1:8000;
    # uwsgi_param UWSGI_PYHOME /mydata/www/;
    # uwsgi_param UWSGI_SCRIPT /mydata/www/;
    # uwsgi_param UWSGI_CHDIR /mydata/www/;
    }

    #error_page 404 /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }

    location /static/ {
    alias /mydata/www/kisspy/static/;
    index index.html index.htm;
    }

    location /media/ {
    alias /mydata/www/kisspy/static/media/;
    }
    }
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    5
    @dingyaguang117
    <uwsgi>
    <socket>127.0.0.1:8000</socket>
    <listen>80</listen>
    <master>true</master>
    <pidfile>/var/run/nginx.pid</pidfile>
    <processes>8</processes>
    <pythonpath>/mydata/www</pythonpath>
    <module>wsgi</module>
    <profiler>true</profiler>
    <memory-report>true</memory-report>
    <enable-threads>true</enable-threads>
    <logdate>true</logdate>
    <limit-as>300</limit-as>
    <daemonize>/mydata/www/log/django.log</daemonize>
    </uwsgi>
    imlonghao
    imlonghao
    Feb 20, 2015 via Android
    6
    <listen>80</listen>
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    7
    主机是阿里云的。奇怪的是把磁盘快照回滚到环境部署好的。还是会出现这个问题。
    imlonghao
    imlonghao
    Feb 20, 2015 via Android
    8
    <pidfile>/var/run/nginx.pid</pidfile>
    <listen>80</listen>

    uwsgi的配置为什么要这样写?
    imlonghao
    imlonghao
    Feb 20, 2015 via Android
    9
    贴一下uwsgi的配置看看?
    imlonghao
    imlonghao
    Feb 20, 2015 via Android
    10
    更正,日志
    imlonghao
    imlonghao
    Feb 20, 2015 via Android
    11
    /mydata/www/log/django.log
    tonghuashuai
    tonghuashuai
    Feb 20, 2015
    12
    <daemonize>/mydata/www/log/django.log</daemonize> 这个地方用 uwsgi 自己的日志文件
    <pidfile>/var/run/nginx.pid</pidfile> 这个地方不应该用 nginx.pid
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    13
    @tonghuashuai <pidfile>/var/run/nginx.pid</pidfile>用什么?
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    14
    @imlonghao
    django.log: {address space usage: 14348288 bytes/13MB} {rss usage: 4497408 bytes/4MB} [pid: 1340|app: -1|req: -1/22] 101.233.154.251 () {42 vars in 657 bytes} [Fri Feb 20 16:22:58 2015] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
    Fri Feb 20 16:22:59 2015 - --- no python application found, check your startup logs for errors ---
    {address space usage: 14348288 bytes/13MB} {rss usage: 4497408 bytes/4MB} [pid: 1345|app: -1|req: -1/23] 101.233.154.251 () {44 vars in 737 bytes} [Fri Feb 20 16:22:59 2015] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
    Fri Feb 20 16:22:59 2015 - --- no python application found, check your startup logs for errors ---
    {address space usage: 14348288 bytes/13MB} {rss usage: 4497408 bytes/4MB} [pid: 1347|app: -1|req: -1/24] 101.233.154.251 () {42 vars in 657 bytes} [Fri Feb 20 16:22:59 2015] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
    dingyaguang117
    dingyaguang117
    Feb 20, 2015 via iPhone
    15
    汗,楼主从哪儿抄的配置
    msg7086
    msg7086
    Feb 20, 2015 via iPhone
    16
    <socket>127.0.0.1:8000</socket>
    <listen>80</listen>
    <pidfile>/var/run/nginx.pid</pidfile>
    我一个不懂python的人都知道这3句都有问题。
    imlonghao
    imlonghao
    Feb 20, 2015
    17
    @msg7086 <socket>127.0.0.1:8000</socket> 这个是没问题的,不过下面两句真的不敢恭维
    imlonghao
    imlonghao
    Feb 20, 2015
    18
    no python application found, check your startup logs for errors
    imlonghao
    imlonghao
    Feb 20, 2015
    19
    我有理由相信你的 <module>wsgi</module> 配置错误

    这是我的配置文件,您可以参考一下
    https://github.com/esdcc/esd.cc/blob/master/esdcc.xml#L6
    这一行所写的 ·wsgi· 对应的是 https://github.com/esdcc/esd.cc/blob/master/wsgi.py

    测试如下,我将我的这个配置改成·<module>1213wsgi</module>· (一个没有对应文件的)
    出现了和你类似的问题

    500


    Log
    imlonghao
    imlonghao
    Feb 20, 2015
    20
    Log
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    21
    @imlonghao 头疼。。服务器一些配置不怎么会,这些配置就是网上找的,话说python也只是刚开始学,还是得继续努力,谢谢你了。
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    22
    @dingyaguang117 配置网上找的。对python感兴趣就学了。其实我是前端。。
    ffx0s
    ffx0s
    OP
    Feb 20, 2015
    23
    @dingyaguang117 网上抄的。
    tonghuashuai
    tonghuashuai
    Feb 21, 2015
    25
    @ffx0s 新建一个 uwsgi.pid
    lsdvincent
    lsdvincent
    Feb 22, 2015
    27
    胆战心惊贴个自己的Blog http://blog.breakwire.me/blog/20150208/ 绝对跑得起来,跑不起来楼主凑我!
    tolerious
    tolerious
    Mar 2, 2015 via iPhone
    28
    把listen那个去掉,不是已经8000端口转发了么?
    1130335361
    1130335361
    Apr 2, 2015
    29
    @lsdvincent 1.logs下面的access.log和error.log是文件还是文件夹?2.需要自己建立吗
    lsdvincent
    lsdvincent
    Apr 3, 2015 via iPhone
    30
    @1130335361 是文件;logs 文件夹要自己建立
    lsdvincent
    lsdvincent
    Apr 3, 2015 via iPhone
    31
    @lsdvincent 只要建那个logs文件夹就行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1414 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 20:20 · PVG 04:20 · LAX 12:20 · JFK 15:20
    ♥ Do have faith in what you're doing.