[uWSGI] dynamic + virtual hosts + virtualenv + django

James unbit at scottisheyes.com
Thu Jul 22 18:29:11 CEST 2010


I'm back with another dynamic virtual hosting/virtualenv question (related
to http://projects.unbit.it/uwsgi/wiki/DynamicVirtualenv).  I've got uwsgi
starting with this:

uwsgi -s /tmp/uwsgi.sock --vhost --no-site -C -M -p4

I've got two separate domains set up with nginx in two separate nginx config
files which get included in the nginx main configuration file:

-------------------

    upstream domain1_upstream {
        server unix:///tmp/uwsgi.sock;
    }

    server {
        listen       80;
        server_name  www.domain1.com;

        location / {
            root /home/www/domain1/project/static;
            uwsgi_pass domain1_upstream;
            include uwsgi_params;
            uwsgi_param SCRIPT_NAME /;
            uwsgi_param UWSGI_SCRIPT config.django_wsgi;
            uwsgi_param UWSGI_PYHOME /home/www/domain1/;
        }
    }

-------------------

and the second file:

-------------------

    upstream domain2_upstream {
        server unix:///tmp/uwsgi.sock;
    }

    server {
        listen       80;
        server_name  www.domain1.com;

        location / {
            root /home/www/domain2/project/static;
            uwsgi_pass domain2_upstream;
            include uwsgi_params;
            uwsgi_param SCRIPT_NAME /;
            uwsgi_param UWSGI_SCRIPT config.django_wsgi;
            uwsgi_param UWSGI_PYHOME /home/www/domain2/;
        }
    }

-------------------

Both of the above files are trimmed down to keep things brief.  Here is the
django_wsgi.py file that the UWSGI_SCRIPT param refers to (it is the same
for both domains):

-------------------

import os, sys
PATH_BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PATH_PROJECT = os.path.join(PATH_BASE, 'project')

activate_this = os.path.join(PATH_BASE, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))

sys.path.append(PATH_PROJECT)
sys.path.append(PATH_BASE)

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

-------------------


I keep getting an "ImportError: No module named django_wsgi" for one of the
domains, but the other one works fine.  I am missing something, but can't
figure out what.  Can someone shed some light on this for me?

Thank you,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.unbit.it/pipermail/uwsgi/attachments/20100722/2a28206b/attachment.htm 


More information about the uWSGI mailing list