私のコンピューターは Ubuntu 12.04 を実行しており、このチュートリアルに従って Django を使い始めました。 10-04/
このコマンドを実行し/srv/www/
てプロジェクトを開始しようとしましたalex
sudo django-admin.py startproject alex
次に、Apacheフォルダーとdjango.wsgi
ファイルを作成しました(/srv/www/alex/apache/django.wsgi
)
ツリー/srv/www/alex/
.
├── apache
│ └── django.wsgi
├── alex
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
2 directories, 6 files
アレックス Apache サイト:
<VirtualHost *:80>
ServerName alex.djangoserver
DocumentRoot /srv/www/alex
<Directory /srv/www/alex>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess alex.djangoserver processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup alex.djangoserver
WSGIScriptAlias / /srv/www/alex/apache/django.wsgi
</VirtualHost>
Apache エラー ログの結果:
[error] [client 127.0.0.1] mod_wsgi (pid=28076): Exception occurred processing WSGI script '/srv/www/floqq/alex/django.wsgi'.
[error] [client 127.0.0.1] Traceback (most recent call last):
[error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
[error] [client 127.0.0.1] self.load_middleware()
[error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
[error] [client 127.0.0.1] for middleware_path in settings.MIDDLEWARE_CLASSES:
[error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
[error] [client 127.0.0.1] self._setup()
[error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
[error] [client 127.0.0.1] self._wrapped = Settings(settings_module)
[error] [client 127.0.0.1] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 95, in __init__
[error] [client 127.0.0.1] raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[error] [client 127.0.0.1] ImportError: Could not import settings 'alex.settings' (Is it on sys.path?): No module named alex.settings
アップデート
Apache/Django.wsgi
import os
import sys
path = '/srv/www'
if path not in sys.path:
sys.path.insert(0, '/srv/www')
os.environ['DJANGO_SETTINGS_MODULE'] = 'alex.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()