照着这个教程搭建 django 环境
[https://github.com/imelucifer/MyNote/blob/master/django/django%2Buwsgi%2Bnginx%2Bcentos部署.md]
安装软件都成功了,单独运行 python manage.py runserver成功。
测试uwsgi 的语句 uwsgi --http :9090 --wsgi-file test.py 也是成功的。
但是当我测试 uwsgi --http :8000 --chdir /root/mysite --module django_wsgi 这句的时候,当我访问
连接的时候,就报错了。
No handlers could be found for logger "django.request"
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 199, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python2.7/site-packages/django/views/debug.py", line 91, in technical_500_response
html = reporter.get_traceback_html()
File "/usr/local/lib/python2.7/site-packages/django/views/debug.py", line 350, in get_traceback_html
return t.render(c)
File "/usr/local/lib/python2.7/site-packages/django/template/base.py", line 148, in render
return self._render(context)
File "/usr/local/lib/python2.7/site-packages/django/template/base.py", line 142, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/site-packages/django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/site-packages/django/template/debug.py", line 80, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/site-packages/django/template/debug.py", line 90, in render
output = self.filter_expression.resolve(context)
File "/usr/local/lib/python2.7/site-packages/django/template/base.py", line 624, in resolve
new_obj = func(obj, *arg_vals)
File "/usr/local/lib/python2.7/site-packages/django/template/defaultfilters.py", line 769, in date
return format(value, arg)
File "/usr/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 343, in format
return df.format(format_string)
File "/usr/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
pieces.append(force_text(getattr(self, piece)()))
File "/usr/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 268, in r
return self.format('D, j M Y H:i:s O')
File "/usr/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
pieces.append(force_text(getattr(self, piece)()))
File "/usr/local/lib/python2.7/site-packages/django/utils/encoding.py", line 85, in force_text
s = six.text_type(s)
File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 144, in __text_cast
return func(*self.__args, **self.__kw)
File "/usr/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 83, in ugettext
return _trans.ugettext(message)
File "/usr/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 325, in ugettext
return do_translate(message, 'ugettext')
File "/usr/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 306, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 209, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 189, in _fetch
"The translation infrastructure cannot be initialized before the "
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
[pid: 15722|app: 0|req: 1/1] 116.3.4.114 () {42 vars in 696 bytes} [Mon Mar 16 07:46:24 2015] GET / => generated 0 bytes in 109 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
看样子像是我django有问题。但是具体什么问题我就看不出来了。求达人指点
环境
阿里云 centos6.5 64位
python 2.7
django 1.7.6
uwsgi 2.0.9
nginx 1.6.2
1
syv2 2015-03-16 17:03:17 +08:00
我记得在初始化项目的时候,settings会自动内置几个loggers,其中就包括了django.request。你这里报的这个错,显然是django_uwsgi内起用了日志,但是找不到django.request这个logger。你需要在settings.LOGGING['loggers']中添加一个logger:
'django.request': {'handerls': [], 'level': 'ERROR'} 试试看呢 |
3
jianghu52 OP @syv2 不好意思啊。我没找到settings.LOGGING这个文件。你要方便的话,能不能帮我看看实际环境呢。我这个阿里云vps没啥东西,你可以随意操作。
vps: 地址: 120.24.54.91 内网 10.169.140.118 账户 root 密码 Win2008admin mysql root mysqladmin |
5
syv2 2015-03-16 18:12:32 +08:00
我已经帮你在settings中添加了这个logger的定义。
|
9
loading 2015-03-16 19:48:08 +08:00
楼主实属勇敢,你如何排除这段时间没人去留后门?
建议重新来吧! |
10
jianghu52 OP 只有一个月生命力的玩意儿,真要是有问题。估计还没等爆发,就消失了。
|
12
jun4rui 2015-03-16 20:08:16 +08:00
Django这种框架你要找新的教程,因为这类玩意老变,经常更新版本命令就不同了,例如老的数据库和新的数据库完全不同了。
这还算好的,Rubyonralis变化更加频繁,貌似ralis style的框架都是如此。所以你要做好准备,不要只看老教程,教程要和你安装的官方最新版文档一起看。最新的是1.76,你的教程是1.55,差距不多也不少。 我也是刚开始玩Django,对照着刚刚了解基础架构, |
13
limbo0 2015-03-16 20:38:34 +08:00
|
14
ericls 2015-03-17 00:52:37 +08:00
教程的django版本太老了
主要是wsgi那一块。。 以前是:django.core.handlers.wsgi:WSGIHandler() 现在是:PROJECT.wsgi:application |
15
ericls 2015-03-17 00:53:38 +08:00
而且Django最好看的还是官方Tutoria
|
16
gevin 2015-03-17 09:05:30 +08:00
看我这篇有没有帮助,我是按这个部署的
http://blog.igevin.info/2014/09/30/deploy-django-with-nginx-and-uwsgi-on-Ubuntu/ 文章最上面链接是英文原文,不行就看原文 |
18
flymyhobby 2015-03-17 15:50:51 +08:00
http://blog.igeek.so/uwsgi-django-nginx/ 照着这个来试试,django 1.6肯定没问题
|
19
ioth 2015-03-17 18:02:27 +08:00
VERSION = (1, 8, 0, 'alpha', 0)
好像没啥问题。 |
20
jianghu52 OP 我现在怀疑是不是因为django配置有什么问题。我在本机模拟装这些个版本的,也是跑不起来,换个django1.6试试看
|
21
Melodic 2015-03-17 23:49:00 +08:00
社工库已经待命
|
22
nick32m 2015-03-18 07:59:49 +08:00
django这么大型复杂, 建议你可以试试小型一点的像flask.
或node js, 超期简单就可以开始工作了... var server = require('http').createServer(); server.listen(port); |