Web サーバーで 2 つの異なるプロジェクトを実行しようとしています。それらを別のドメインで指すようにしたい。そこで、httpd.conf を次のように構成しました。
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin me@web1.com
ServerName www.web1.com
WSGIScriptAlias / /var/www/web1/web1/wsgi.py
<Directory /var/www/web1/web1>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
ErrorLog logs/dummy-host.web1.com-error_log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me@web2.com
ServerName www.web2.com
ServerAlias web2.com *.web2.com
WSGIScriptAlias / /var/www/web2/web2/wsgi.py
<Directory /var/www/web2/web2>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
ErrorLog logs/dummy-host.web2.com-error_log
</VirtualHost>
この構成で、httpd を実行して web1.com に正常にアクセスできます。しかし、web2.com にアクセスしようとすると、「内部サーバー エラー」が表示されます。ログを確認したところ、myblog(web2) プロジェクトで設定した「DJANGO_SETTINGS_MODULE」が web1 のプロジェクトに上書きされているようでした。この問題を解決する方法を知っている体はありますか?ありがとうございました!
<code>
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] mod_wsgi (pid=27246): Exception occurred processing WSGI script '/var/www/myblog/myblog/wsgi.py'.
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] Traceback (most recent call last):
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] self.load_middleware()
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 39, in load_middleware
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] for middleware_path in
settings.MIDDLEWARE_CLASSES:
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] File "/usr/lib/python2.6/site-packages/django/utils/functional.py", line 184, in inner
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] self._setup()
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 42, in _setup
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] self._wrapped = Settings(settings_module)
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 95, in __init__
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Thu Jan 10 00:22:38 2013] [error] [client 220.181.108.97] ImportError: Could not import settings 'myblog.settings' (Is it on sys.path?): No module named myblog.settings
~
</code>