我試圖部署我的Django應用程序在我的linode服務器與Apache和mod_wsgi。Django + mod_wsgi + apache:導入錯誤在/沒有模塊名爲djproj.urls
file: /srv/www/example.com/djproj/django.wsgi
import os
import sys
sys.path.append('/srv/www/example.com/djproj')
os.environ['PYTHON_EGG_CACHE'] = '/srv/www/example.com/.python-egg'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
file: /etc/apache2/sites-available/example.com
/etc/apache2/sites-available/example.com
ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
DocumentRoot /srv/www/example.com/public_html
WSGIScriptAlias//srv/www/example.com/djproj/django.wsgi
<Directory "/srv/www/example.com/djproj">
Order allow,deny
Allow from all
</Directory>
ErrorLog /srv/www/example.com/logs/error.log
CustomLog /srv/www/example.com/logs/access.log combined
當我訪問我的網站/我得到這個錯誤:
Environment:
Request Method: GET
Request URL: http://example.com/
Django Version: 1.3
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3- py2.6.egg/django/core/handlers/base.py" in get_response
101. request.path_info)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py 2.6.egg/django/core/urlresolvers.py" in resolve
250. for pattern in self.url_patterns:
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in _get_url_patterns
279. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/urlresolvers.py" in _get_urlconf_module
274. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/utils/importlib.py" in import_module
35. __import__(name)
Exception Type: ImportError at/
Exception Value: No module named djproj.urls
我無法讓它工作。想法?
這也是我的問題。爲什麼地獄不是在文檔中提到的,儘管!!!!!!!!!!我以爲你只需要指定DJANGO_SETTINGS_MODULE,然後django就可以完成剩下的工作。 – Sam 2011-05-13 12:04:37
請注意,該路徑實際上應該讀取「/srv/www/site.com」**,因爲這與提問者在他們的問題**中提出的內容相匹配。 – 2014-03-20 05:40:40