[uWSGI] dynamic + virtual hosts + virtualenv + django

James unbit at scottisheyes.com
Thu Jul 22 22:40:39 CEST 2010


Thanks for the reply, Stephen - the imports you suggest within the python
shells appear to work just fine, so that doesn't appear to be the problem.

Cheers,
James

On Thu, Jul 22, 2010 at 9:48 AM, Stephen Crosby <stevecrozz at gmail.com>wrote:

> Start an interactive python shell from each of your two web roots (/home/www/domain2/project/static
> and /home/www/domain1/project/static) and try issuing:
>
> from config import django_wsgi
>
> If one of them fails with an ImportError, but the config/django_wsgi.py
> file is really there, you could just be missing an __init__.py file inside
> the config directory which is what tells python to treat that folder as a
> package directory.
>
> On Thu, Jul 22, 2010 at 9:29 AM, James <unbit at scottisheyes.com> wrote:
>
>> 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
>>
>> _______________________________________________
>> uWSGI mailing list
>> uWSGI at lists.unbit.it
>> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>>
>>
>
>
> --
> Stephen Crosby
> Web Developer
> lithostech.com
>
> _______________________________________________
> uWSGI mailing list
> uWSGI at lists.unbit.it
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.unbit.it/pipermail/uwsgi/attachments/20100722/7d1b7ac8/attachment-0001.htm 


More information about the uWSGI mailing list