我已經安裝好了Python,我可以在命令行運行腳本就好了。但我想用它構建網頁,並使用Django框架。第一次讓Django/WSGI運行,有一些問題
我已閱讀了大量有關如何設置和獲取django運行的文檔。 大多數工作都是使用apt-get安裝完成的,它安裝了所有需要的東西,但是我遇到了虛擬主機配置問題。目前我正在收到500服務器錯誤,並在錯誤日誌中看到導入錯誤。
下面是完整的虛擬主機文件:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName friendflix.me
ServerAlias www.friendflix.me
DocumentRoot "/srv/www/friendflix.me/public_html/"
ErrorLog /srv/www/friendflix.me/logs/error.log
CustomLog /srv/www/friendflix.me/logs/access.log combined
WSGIScriptAlias//srv/www/friendflix.me/application/django.wsgi
<Directory /srv/www/friendflix.me/application>
Order allow,deny
Allow from all
</Directory>
<Location "/application">
SetHandler python-program
PythonOption django.root /application
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonPath "['/srv/www/friendflix.me/application', '/srv/www/friendflix.me/publ$
PythonDebug On
</Location>
Alias /static /srv/www/friendflix.me/public_html/static
</VirtualHost>
尾error.log中的應用程序(或至少)
HTML根
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] self.load_middleware()
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 276, in __getattr__
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] self._setup()
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 42, in _setup
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] self._wrapped = Settings(settings_module)
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 89, in __init__
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Sun Jun 19 21:28:07 2011] [error] [client 74.89.144.194] ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings
目錄結構
/srv/www/friendflix.me/public_html
applicati根
/srv/www/friendflix.me/application
的Django/WSGI應用程序配置
/srv/www/friendflix.me/application/django.wsgi
Django.wsgi腳本
import os
import sys
sys.path.append('/srv/www/friendflix.me/application')
os.environ['PYTHON_EGG_CACHE'] = '/srv/www/friendflix.me/.python-egg'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
任何幫助解決這一問題將是巨大的 - 謝謝! 富
你能請張貼進口錯誤的詳細信息? –
您的配置被截斷。 –
請發佈您的應用程序的目錄結構 –