最近我在 Apache 上使用 django 和 mod_wsgi。
我按照网页中的以下步骤操作:
“我的应用在/mnt/www/,名字叫mysite,apache并在mysite media目录下创建,然后执行以下操作:”
创建 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 Server Error。然后我检查 erro_log:它说:“TemplateSyntaxError: Caught ImportError while rendering: No module named friends”(friends 是我的一个模块的名称)
我网站的路径是 /var/BigPrject/mysite