500 互联网服务器错误 error_log:TemplateSyntaxError: 渲染时捕获 ImportError: 没有名为friends 的模块
最近我在 Apache 上使用 django 和 mod_wsgi。
我是按照以下步骤在网页中找到的:
“我的应用程序在/mnt/www/,名称叫mysite,apache,并在mysite媒体目录中创建,然后执行以下操作:”
创建 apache_django_wsgi.conf 文件,如下:
Alias / site_media / / mnt / www / mysite / media /
<Directory /mnt/www/mysite/media>
Order allow, deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</ Directory>
Alias / media / / usr/local/lib/python2.5/site-packages/django/contrib/admin/media /
<Directory /usr/local/lib/python2.5/site-packages/django/contrib/admin/media>
Order allow, deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</ Directory>
WSGIScriptAlias / / mnt / www / mysite / apache / django.wsgi
<Directory /mnt/www/mysite>
Order deny, allow
Allow from all
</ Directory>
<Directory /mnt/www/mysite/apache>
Allow from all
</ Directory>
创建 django.wsgi 文件,如下:
import os, sys
# Calculate the path based on the location of the WSGI script.
apache_configuration = os.path.dirname (__file__)
project = os.path.dirname (apache_configuration)
workspace = os.path.dirname (project)
sys.path.append (workspace)
os.environ ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
os.environ ['PYTHON_EGG_CACHE'] = '/ tmp'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler ()
print>> sys.stderr, sys.path
我已按照这些步骤操作,但是当我通过浏览器在 Apache 下运行它时,出现 500 Internet 服务器错误。然后我检查 erro_log:它说:“TemplateSyntaxError:渲染时捕获导入错误:没有名为friends的模块”(friends 是我的模块之一的名称)
我的站点的路径是 /var/BigPrject/mysite
Recently I am using django and mod_wsgi on Apache.
I am follow the following steps found in a webpage:
"My application in / mnt / www /, the name of the called mysite, apache and created in the mysite media directory, and then do the following:"
create apache_django_wsgi.conf file, as follows:
Alias / site_media / / mnt / www / mysite / media /
<Directory /mnt/www/mysite/media>
Order allow, deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</ Directory>
Alias / media / / usr/local/lib/python2.5/site-packages/django/contrib/admin/media /
<Directory /usr/local/lib/python2.5/site-packages/django/contrib/admin/media>
Order allow, deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</ Directory>
WSGIScriptAlias / / mnt / www / mysite / apache / django.wsgi
<Directory /mnt/www/mysite>
Order deny, allow
Allow from all
</ Directory>
<Directory /mnt/www/mysite/apache>
Allow from all
</ Directory>
create django.wsgi file, as follows:
import os, sys
# Calculate the path based on the location of the WSGI script.
apache_configuration = os.path.dirname (__file__)
project = os.path.dirname (apache_configuration)
workspace = os.path.dirname (project)
sys.path.append (workspace)
os.environ ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
os.environ ['PYTHON_EGG_CACHE'] = '/ tmp'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler ()
print>> sys.stderr, sys.path
I have followed these step but when I run it under Apache through a browser, I get a 500 Internet Server Error. Then I check the erro_log: it says:"TemplateSyntaxError: Caught ImportError while rendering: No module named friends" (friends is the name of one of my module)
The path of my site is /var/BigPrject/mysite
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说一切看起来都很好,除了项目文件夹不在 python 路径中。
您可以通过转到控制台并尝试
导入朋友
来验证它。我猜,在您的情况下,您可以通过将以下行添加到您的
wsgi
文件中来解决此问题:Everything looks good to me, except the project folder is not in the python path.
You can validate it by going to the console and trying to
import friends
.I am guessing, you can fix this, in you case, by adding the following line to your
wsgi
file: