I am trying to follow the steps in this guide: http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
我正在尝试遵循本指南中的步骤:http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Before I even get to the nginx part I am trying to make sure that uWSGI works correctly
在我开始讲nginx部分之前,我要确保uWSGI的工作是正确的
my folder structure is srv/www/domain/projectdatabank/
我的文件夹结构是srv/www/domain/projectdatabank/。
the project databank folder contains my manage.py file
项目数据库文件夹包含我的管理。py文件
my wsgi.py file looks like this:
我的wsgi。py文件如下所示:
import os
import sys
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
do you need to see my settings.py?
你要看我的住处吗?
i get the following error when i point myself to the browser:
当我指向浏览器时,我得到如下错误:
-- no python application found, check your startup logs for errors --- [pid: 10165|app: -1|req: -1/1] 66.56.35.151 () {38 vars in 681 bytes} [Tue Jul 9 18:19:46 2013] GET /admin/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 1 headers in 57 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 10165|app: -1|req: -1/2] 66.56.35.151 () {36 vars in 638 bytes} [Tue Jul 9 18:19:49 2013] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 1 headers in 57 bytes (0 switches on core 0)
——没有python应用程序发现,检查你的启动日志错误- - - - - -[pid:10165 |应用:1 |要求:-1/1)66.56.35.151(){ var 38 681字节}(2013年7月9日18:19:46星期二)得到/ admin / = >生成21字节0毫秒断开(HTTP / 1.1 500)1头在57个字节(0交换机核心0)- - -没有发现python应用程序,检查你的启动日志错误- - - - - -[pid:10165 |应用:1 |要求:{36 vars in 638 bytes} [Tue Jul 9 18:19:49 2013] GET / =>在0 msecs (HTTP/1.1 500)中生成21个字节在57字节(内核0开关0)
Now when I check my uWGI log it is just the same as above.
现在当我检查uWGI日志时,它和上面一样。
3 个解决方案
#1
37
I have solved this
我已经解决了这个
in my original command line did not include full path to the wsgi.py file to run uWSGI
在我的原始命令行中,没有包括到wsgi的完整路径。运行uWSGI的py文件
uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file wsgi.py
to this
这个
uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file full/path/wsgi.py
and it worked
这工作
#2
30
For others debugging this same error, there is another possibility: an exception is being thrown by your uwsgi.py
. To test this, open a django shell in your app directly with python manage.py shell
and import your uwsgi.py
(use the same path as in your uwsgi.ini
).
对于调试相同错误的其他人,还有另一种可能性:uwsgi.py抛出了一个异常。要测试这一点,可以使用python管理在应用程序中直接打开django shell。py shell并导入uwsgi。py(使用与uwsgi.ini中相同的路径)。
#3
10
Check out my blog post on deploying Django behind uwsgi http://blog.johannesklug.de/2012/11/27/deploying-django-behind-nginx-with-uwsgi-and-virtualenv/. I created an ini-File to setup uwsgi, which points to the app callable with the parameter module=project.wsgi:application
.
查看我关于在uwsgi http://blog.johannesklug.de/2012/11/27/部署- Django背后部署Django的博客文章。我创建了一个ini文件来设置uwsgi,它指向可以使用parameter module=project.wsgi:application调用的应用程序。
The whole file reads something like this:
整个文件是这样的:
(env)[project@host ~]$ cat uwsgi.ini
[uwsgi]
# path to where you put your project code
chdir=/home/project/project
# python path to the wsgi module, check if you have one
module=project.wsgi:application
# this switch tells uwsgi to spawn a master process,
# that will dynamically spawn new child processes for
# server requests
master=True
# uwsgi stores the pid of your master process here
pidfile=/home/project/master.pid
vacuum=True
# path to your virtual environment
home=/home/project/env/
# path to log file
daemonize=/home/project/log
# this is where you need to point nginx to,
# if you chose to put this in project home make
# sure the home dir is readable and executable by
# nginx
socket=/tmp/uwsgi.sock
### SEE UPDATE NOTICE FOR THIS ONE
env = DJANGO_SETTINGS_MODULE=project.settings
Please note that I'm using virtualenv.
请注意,我正在使用virtualenv。
You might also be missing the lines
你也可能漏掉了台词
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
in your wsgi.py
在你wsgi.py
#1
37
I have solved this
我已经解决了这个
in my original command line did not include full path to the wsgi.py file to run uWSGI
在我的原始命令行中,没有包括到wsgi的完整路径。运行uWSGI的py文件
uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file wsgi.py
to this
这个
uwsgi --http :8000 --chdir /srv/www/databankinfo.com/projectdatabank/ --wsgi-file full/path/wsgi.py
and it worked
这工作
#2
30
For others debugging this same error, there is another possibility: an exception is being thrown by your uwsgi.py
. To test this, open a django shell in your app directly with python manage.py shell
and import your uwsgi.py
(use the same path as in your uwsgi.ini
).
对于调试相同错误的其他人,还有另一种可能性:uwsgi.py抛出了一个异常。要测试这一点,可以使用python管理在应用程序中直接打开django shell。py shell并导入uwsgi。py(使用与uwsgi.ini中相同的路径)。
#3
10
Check out my blog post on deploying Django behind uwsgi http://blog.johannesklug.de/2012/11/27/deploying-django-behind-nginx-with-uwsgi-and-virtualenv/. I created an ini-File to setup uwsgi, which points to the app callable with the parameter module=project.wsgi:application
.
查看我关于在uwsgi http://blog.johannesklug.de/2012/11/27/部署- Django背后部署Django的博客文章。我创建了一个ini文件来设置uwsgi,它指向可以使用parameter module=project.wsgi:application调用的应用程序。
The whole file reads something like this:
整个文件是这样的:
(env)[project@host ~]$ cat uwsgi.ini
[uwsgi]
# path to where you put your project code
chdir=/home/project/project
# python path to the wsgi module, check if you have one
module=project.wsgi:application
# this switch tells uwsgi to spawn a master process,
# that will dynamically spawn new child processes for
# server requests
master=True
# uwsgi stores the pid of your master process here
pidfile=/home/project/master.pid
vacuum=True
# path to your virtual environment
home=/home/project/env/
# path to log file
daemonize=/home/project/log
# this is where you need to point nginx to,
# if you chose to put this in project home make
# sure the home dir is readable and executable by
# nginx
socket=/tmp/uwsgi.sock
### SEE UPDATE NOTICE FOR THIS ONE
env = DJANGO_SETTINGS_MODULE=project.settings
Please note that I'm using virtualenv.
请注意,我正在使用virtualenv。
You might also be missing the lines
你也可能漏掉了台词
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
in your wsgi.py
在你wsgi.py