How to run different Django projects under different Domains on one web server?
Question: I am trying to running two different projects in my web server. I want them to
be pointed by different domain. So I configured my httpd.conf like this:

    
    
    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>
    

**With this configuration, I can run httpd and visit web1.com successfully.
However, when I tried to visit web2.com, a "Internal Server Error" appear. So
I went to check the log, it seemed that the "DJANGO_SETTINGS_MODULE" set by
myblog(web2) project is overrided by that of web1? Does any body know how to
solve this problem? Thank you!**

    
    
    <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>
    


Answer: One Suggestion would be to create 2 virtual hosts in your apache configuration

    
    
    www.web1.com on 80
    

and

    
    
    www.web2.com on 81
    

