The pinax documents have sample .wsgi scripts and deployment configuration
info that has worked for me.  My .wsgi script, placed in a subdirectory of the
directory looks like:
--------------------------------------------
import os, sys
sys.stdout = sys.stderr

from os.path import abspath, dirname, join
from site import addsitedir

sys.path.insert(0, abspath(join(dirname(__file__), "../../")))

from django.conf import settings
os.environ["DJANGO_SETTINGS_MODULE"] = "name_of_project_directory.settings"

sys.path.insert(0, join(settings.PINAX_ROOT, "apps"))
sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
-----------------------------------------------
Replace name_of_project_directory with the name of your project directory
in DJANGO_SETTINGS_MODULE, or use
    os.basename(os.dirname(os.dirname(__file__))) + '.settings'

Bill
On Fri, Jul 23, 2010 at 1:57 PM, Nathan Smith <nat...@nathansmith.me> wrote:
> I'm trying to use mod_wsgi to serve a Django/Pinax site using a
> virtualenv, but have not had luck so far. It seems that my
> WSGIPythonHome directive is not being followed, because I get import
> errors, and on those, the system Python path is being shown, not my
> virtual env. When trying to access the site, I get an error 500.
> Apache log:
>
> [warn] mod_wsgi: Compiled for Python/2.6.1+.
> [warn] mod_wsgi: Runtime using Python/2.6.2.
> [warn] mod_wsgi: Python module path '/usr/lib/python2.6/:/usr/lib/
> python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-
> old:/usr/lib/python2.6/lib-dynload'.
> [notice] Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.5 with Suhosin-
> Patch mod_ssl/2.2.11 OpenSSL/0.9.8g mod_wsgi/2.3 Python/2.6.2
> configured -- resuming normal operations
> [error] [client ] mod_wsgi (pid=29437): Exception occurred processing
> WSGI script '/home/ndansmith/django/api/wsgi_handler.py'.
> [error] [client ] Traceback (most recent call last):
> [error] [client ]   File "/var/lib/python-support/python2.6/django/
> core/handlers/wsgi.py", line 228, in __call__
> [error] [client ]     self.load_middleware()
> [error] [client ]   File "/var/lib/python-support/python2.6/django/
> core/handlers/base.py", line 31, in load_middleware
> [error] [client ]     for middleware_path in
> settings.MIDDLEWARE_CLASSES:
> [error] [client ]   File "/var/lib/python-support/python2.6/django/
> conf/__init__.py", line 28, in __getattr__
> [error] [client ]     self._import_settings()
> [error] [client ]   File "/var/lib/python-support/python2.6/django/
> conf/__init__.py", line 59, in _import_settings
> [error] [client ]     self._target = Settings(settings_module)
> [error] [client ]   File "/var/lib/python-support/python2.6/django/
> conf/__init__.py", line 94, in __init__
> [error] [client ]     raise ImportError, "Could not import settings
> '%s' (Is it on sys.path? Does it have syntax errors?): %s" %
> (self.SETTINGS_MODULE, e)
> [error] [client ] ImportError: Could not import settings
> 'api.settings' (Is it on sys.path? Does it have syntax errors?): No
> module named pinax
>
> As you can see, it is using my system Python. Here is the apache vhost
> config:
>
> WSGIPythonHome /var/venv/ooss
> <VirtualHost *:80>
>    ServerName api.ossandbox.info
>    ServerAdmin nat...@ndansmith.net
>    WSGIScriptAlias / /home/ndansmith/django/api/wsgi_handler.py
>    WSGIDaemonProcess api.ossandbox.info processes=1 threads=10
>    WSGIProcessGroup api.ossandbox.info
>    <Location "/">
>        Allow from all
>    </Location>
> </VirtualHost>
>
> /var/venv/oss was created with --no-site-packages, and it has the
> pinax package installed
>
> My wsgi script:
> import sys
> import os
> sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'api.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> I have tried changing WSGIPythonHome to an invalid directory, and
> there is no error, so it looks like the directive is being ignored. I
> can serve wsgi sites using the system path. Any suggestions are
> welcome. Let me know if you need more info.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To post to this group, send email to modw...@googlegroups.com.
> To unsubscribe from this group, send email to 
> modwsgi+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/modwsgi?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to modw...@googlegroups.com.
To unsubscribe from this group, send email to 
modwsgi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to