Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem with nginx + uwsgi in vhost mode, running django app
    text
    copied!<p>I have a couple of django apps on my servers, running perfectly on their own socket file, but i plan to introduce some more django apps, so i prefer to run uwsgi in vhost mode, but it seems to have some problem with the import/paths</p> <p>Here is the nginx virtualhost configuracion </p> <pre><code>location / { include uwsgi_params; uwsgi_param UWSGI_PYHOME /home/httpd/django.udm.local/public_html; uwsgi_param UWSGI_PYHOME /home/httpd/django.udm.local/public_html; uwsgi_param UWSGI_PYTHONPATH /home/httpd/django.udm.local/public_html; uwsgi_param UWSGI_CHDIR /home/httpd/django.udm.local/public_html uwsgi_param UWSGI_ENV DJANGO_SETTINGS_MODULE=settings; uwsgi_param UWSGI_MODULE mysite; uwsgi_pass 127.0.0.1:1088; </code></pre> <p>and in the "mysite.py" file i have this:</p> <pre><code>import os, sys sys.path.append(os.path.dirname(__file__)) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() </code></pre> <p>i'm running uwsgi with this command:</p> <pre><code>uwsgi -s 127.0.0.1:1088 -M --no-site --vhost </code></pre> <p>and HERE is the error</p> <pre><code>*** Operational MODE: single process *** *** no app loaded. going in full dynamic mode *** *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 1838) spawned uWSGI worker 1 (pid: 1839, cores: 1) Traceback (most recent call last): File "./mysite.py", line 7, in &lt;module&gt; import django.core.handlers.wsgi ImportError: No module named django.core.handlers.wsgi unable to load app SCRIPT_NAME=django.udm.local| </code></pre> <p>as you can imagine, django is correctly installed on the system </p> <pre><code># python Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import django.core.handlers.wsgi &gt;&gt;&gt; </code></pre> <p>thanks!</p> <p><strong>UPDATE</strong> 18/8 finally i've found the solution.. i've changed the mysite.py file and added the paths to django and the python libs </p> <pre><code>import os, sys sys.path.append(os.path.dirname(__file__)) sys.path.append('/usr/lib/pymodules/python2.6') sys.path.append('/usr/lib/python2.6/dist-packages') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload