On 27 May 2011 08:57, Dan O'Donovan <[email protected]> wrote:
> Hi Graham,
>
> Thanks so much for your help before, and for the continued development
> of mod_wsgi - it's such linchpin product in many site. I'm astounded
> by your efforts esp. as you say you don't run it yourself.
>
> I've a slightly cooked up scenario where I've compiled mod_wsgi with a
> custom (enthought) python distribution. I have had to use patchelf to
> get mod_wsgi.so to search the correct library paths to find
> libpython.so. This doesn't seem to be a big issue as things work - see
> below.
>
> I would like mod_wsgi to source a virtualenv python clone of the epd
> python. This works absolutely wonderfully if I set PYTHONHOME=/path/to/
> virtualenv in a terminal and start apache from that terminal.
>
> But - (as you may guess) when I try to get this to run daemonized (ie
> with $ service httpd restart  - or whatever as if the system was
> booting) then this fails. I set either (or both) of
>
> WSGIPythonHome          /path/to/virtualenv
> SetEnv                  PYTHONHOME  /path/to/virtualenv

The SetEnv would have no affect as that would only appear if WSGI
environ dictionary passed to request. Doesn't cause environment
variables to be set.

> in httpd.conf and I get the following information messages from
> error.log
>
> [Thu May 26 18:53:26 2011] [info] mod_wsgi (pid=19324): Python home /
> path/to/virtualenv.
> [Thu May 26 18:53:26 2011] [info] mod_wsgi (pid=19324): Initializing
> Python.
> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
> ImportError: No module named site
>
>
> Of course, setting $PYTHONHOME works - but I can't set $PYTHONHOME
> from during boot (or simple daemon restart) or can I?

For a standard Apache software foundation installation that hasn't
been morphed too much by the Linux distribution, there is a 'envvars'
file in the same directory as 'httpd' executable. You can stick:

  PYTHONHOME=/path/to/virtualenv
  export PYTHONHOME

in that.

The WSGIPythonHome directive should serve exactly the same purpose though.

Try that first, ensuring that when you restart Apache you do it as:

  sudo -H ....

presuming you are using sudo to run appropriate restart command.

The -H option ensures that personal HOME directory variable, any maybe
other stuff, isn't inherited by the shell which does the restart.

You might also in the envvars file put:

  PYTHONVERBOSE=1
  export PYTHONVERBOSE

This will cause Python to dump out lots of extra debug while running
about imports etc. It might give a clue.

Graham

> Does this sound familiar and could you help? I have tried (and
> appreciated) your thorough documentation but find myself stuck on
> this.
>
> Many thanks,
>
> Dan
>
> --
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to