django+uwsgi+nginx 出现问题

2015-02-20 13:12:16 +08:00
 ffx0s

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"。求解所方法。

12329 次点击
所在节点    Python
31 条回复
dingyaguang117
2015-02-20 14:15:56 +08:00
uwsgi配置贴一下
surefire
2015-02-20 15:22:33 +08:00
8000端口没开吧
ffx0s
2015-02-20 15:28:36 +08:00
@surefire 开了。
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN
ffx0s
2015-02-20 15:29:56 +08:00
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
2015-02-20 15:32:37 +08:00
@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
2015-02-20 15:37:56 +08:00
<listen>80</listen>
ffx0s
2015-02-20 15:38:21 +08:00
主机是阿里云的。奇怪的是把磁盘快照回滚到环境部署好的。还是会出现这个问题。
imlonghao
2015-02-20 15:43:37 +08:00
<pidfile>/var/run/nginx.pid</pidfile>
<listen>80</listen>

uwsgi的配置为什么要这样写?
imlonghao
2015-02-20 15:52:17 +08:00
贴一下uwsgi的配置看看?
imlonghao
2015-02-20 15:52:31 +08:00
更正,日志
imlonghao
2015-02-20 15:53:00 +08:00
/mydata/www/log/django.log
tonghuashuai
2015-02-20 16:06:24 +08:00
<daemonize>/mydata/www/log/django.log</daemonize> 这个地方用 uwsgi 自己的日志文件
<pidfile>/var/run/nginx.pid</pidfile> 这个地方不应该用 nginx.pid
ffx0s
2015-02-20 18:21:29 +08:00
@tonghuashuai <pidfile>/var/run/nginx.pid</pidfile>用什么?
ffx0s
2015-02-20 18:22:32 +08:00
@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
2015-02-20 19:01:02 +08:00
汗,楼主从哪儿抄的配置
msg7086
2015-02-20 19:11:46 +08:00
<socket>127.0.0.1:8000</socket>
<listen>80</listen>
<pidfile>/var/run/nginx.pid</pidfile>
我一个不懂python的人都知道这3句都有问题。
imlonghao
2015-02-20 19:34:30 +08:00
@msg7086 <socket>127.0.0.1:8000</socket> 这个是没问题的,不过下面两句真的不敢恭维
imlonghao
2015-02-20 19:37:11 +08:00
no python application found, check your startup logs for errors
imlonghao
2015-02-20 19:45:17 +08:00
我有理由相信你的 <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
2015-02-20 19:51:08 +08:00
Log

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/171896

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX