Django配置问题

时间:2011-05-02 15:24:19

标签: django apache2

我有一个我想要发布的网站。使用ruserver命令时,该站点运行正常。

但是,当我尝试在apache服务器上运行它时,我得到:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, email@domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

查看日志,有时它没有任何新内容,有时它有:

[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]     return     do_translate(message, 'ugettext')
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]   File "/usr/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 270, in do_translate
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]     _default = translation(settings.LANGUAGE_CODE)
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]   File "/usr/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 180, in translation
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]     default_translation = _fetch(settings.LANGUAGE_CODE)
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]   File "/usr/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 163, in _fetch
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]     app = import_module(appname)
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]   File "/usr/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195]     __import__(name)
[Mon May 02 10:21:21 2011] [error] [client 78.83.251.195] TemplateSyntaxError: Caught ImportError while rendering: No module named main

但是,我确实将模块'main'作为文件夹和settings.py中的应用程序

事实上,如果我在设置中注释掉'main',它会在下一个'app'上发现类似的错误,直到我将它们全部删除,当然没有任何效果。

这是httpd.conf:

<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin email@domain.com
ServerName  domain.com
ServerAlias domain.com
Alias /admin_media/ /usr/lib/python2.6/dist-packages/django/contrib/admin/media/

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /var/www/domain.com/

# Custom log file locations
LogLevel warn
ErrorLog  /var/www/domain.com/log/error.log
CustomLog /var/www/domain.com/log/access.log combined

    # Setup mod_wsgi
    WSGIScriptAlias / /var/www/domain.com/dispatch.wsgi

    <Directory /var/www/domain.com >
            Order deny,allow
            Allow from all
    </Directory>
</VirtualHost>

我该怎么办?

1 个答案:

答案 0 :(得分:1)

在您的apache httpd.conf文件中,您必须确保项目路径位于WSGIPythonPath

WSGIPythonPath /home/user/webapps/yourproject:/home/user/webapps/yourproject/project:/home/user/webapps/yourproject/lib/python2.7

我假设您的settings.py位于project

之下
/home/user/webapps/yourproject/project/settings.py