2010/1/22 toinbis <[email protected]>:
> Graham,
>
> thanks a lot for devoting your time and energy to help me (even more
> thanks for mod_wsgi overall!:).
>
>
> Setting correct WSGIPythonExecutable or WSGIPythonHome didn't help.
>
> ldd mod_wsgi.so output is
> linux-gate.so.1 => (0x00381000)
> libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00add000)
> libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0x00a80000)
> libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x00110000)
> libutil.so.1 => /lib/tls/i686/cmov/libutil.so.1 (0x00114000)
> libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x001f0000)
> libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00386000)
> libz.so.1 => /lib/libz.so.1 (0x00118000)
> /lib/ld-linux.so.2 (0x00581000)
>
> so i've started playing around with setting the PATH and
> LD_LIBRARY_PATH env variables.
>
> But as i need to travel a bit tomorow, I'll finish the testing and
> post the results of the PATH and LD_LIBRARY_PATH "method'
> in two days, hope that's fine.
>
> thanks again,
> greetings,
> to
>
> p.s. this is the bin/python (as said, just a wrapper script), maybe
> it's important as well...:
Yep. It isn't a real Python installation and you should not be using
it with --with-python for mod_wsgi. Use the normal Python version it
refers to.
The real problem is likely that you aren't setting sys.path from WSGI
script the same way this custom Python wrapper is doing it.
So, in your WSGI script file for mod_wsgi, do something like:
import sys
sys.path[0:0] = [
'/home/toinbis/Desktop/programming/project/src',
'/home/toinbis/Desktop/programming/project/eggs/Django-1.1.1-
py2.6.egg',
'/home/toinbis/Desktop/programming/project/eggs/MySQL_python-1.2.3c1-
py2.6-linux-i686.egg',
'/home/toinbis/Desktop/programming/project/eggs/setuptools-0.6c11-
py2.6.egg',
'/home/toinbis/Desktop/programming/project/parts/djangosphinxgit',
'/home/toinbis/Desktop/programming/project/parts/sqlalchemyhg/lib',
'/home/toinbis/Desktop/programming/project/parts/svnapps/
sphinxsearchtrunk/api',
'/home/toinbis/Desktop/programming/project/src/tsd',
]
at the start.
Graham
> #!/usr/bin/python
>
> import sys
>
> try:
> if sys.argv[1] == '-u':
> sys.argv.remove('-u')
> except:
> pass
>
> sys.path[0:0] = [
> '/home/toinbis/Desktop/programming/project/src',
> '/home/toinbis/Desktop/programming/project/eggs/Django-1.1.1-
> py2.6.egg',
> '/home/toinbis/Desktop/programming/project/eggs/MySQL_python-1.2.3c1-
> py2.6-linux-i686.egg',
> '/home/toinbis/Desktop/programming/project/eggs/setuptools-0.6c11-
> py2.6.egg',
> '/home/toinbis/Desktop/programming/project/parts/djangosphinxgit',
> '/home/toinbis/Desktop/programming/project/parts/sqlalchemyhg/lib',
> '/home/toinbis/Desktop/programming/project/parts/svnapps/
> sphinxsearchtrunk/api',
> '/home/toinbis/Desktop/programming/project/src/tsd',
> ]
>
> _interactive = True
> if len(sys.argv) > 1:
> _options, _args = __import__("getopt").getopt(sys.argv[1:],
> 'ic:m:')
> _interactive = False
> for (_opt, _val) in _options:
> if _opt == '-i':
> _interactive = True
> elif _opt == '-c':
> exec _val
> elif _opt == '-m':
> sys.argv[1:] = _args
> _args = []
> __import__("runpy").run_module(
> _val, {}, "__main__", alter_sys=True)
>
> if _args:
> sys.argv[:] = _args
> __file__ = _args[0]
> del _options, _args
> execfile(__file__)
>
> if _interactive:
> del _interactive
> __import__("code").interact(banner="", local=globals())
>
>
>
> On Jan 21, 1:31 pm, Graham Dumpleton <[email protected]>
> wrote:
>> Presuming that:
>>
>> /home/toinbis/Desktop/programming/project/bin/python
>>
>> is the Python you wanted used, what do you get when you run that and do:
>>
>> import sys
>> print sys.prefix
>>
>> Whatever the value of sys.prefix is for the Python you want used, add it as:
>>
>> WSGIPythonHome <value of sys.prefix>
>>
>> Replacing <value of sys.prefix> as appropriate.
>>
>> Do not set WSGIPythonExecutable in this case.
>>
>> Alternatively, set:
>>
>> WSGIPythonExecutable /home/toinbis/Desktop/programming/project/bin/python
>>
>> Do not set WSGIPythonHome in this case.
>>
>> If that doesn't help, then also post the output of running:
>>
>> ldd mod_wsgi.so
>>
>> If that doesn't reference a libpython2.6.so from the buildout Python
>> installation, you are going to have to do some trickery.
>>
>> The easiest way is to locate the directory where the correct
>> libpython2.6.so will be installed into and then find the 'envars' file
>> in the same directory as the 'httpd' binary for your buildout
>> installation. Modify that file to include:
>>
>> PATH=<directory containing the correct python executable>:$PATH
>> export PATH
>>
>> LD_LIBRARY_PATH=<directory containing the libpython2.6.so>:$LD_LIBRARY_PATH
>> export LD_LIBRARY_PATH
>>
>> In short though, the basic problem is that you have multiple Python
>> 2.6 installations on the same system and the way Python works it will
>> use as base reference for Python installation the 'python' executable
>> it finds in the PATH use environment variable. For Apache we therefore
>> need to override in the envvars file what PATH is and therefore what
>> Python it finds else it may use system wide installed Python as base.
>> The LD_LIBRARY_PATH is similarly needed where libpython2.6.so is not
>> in a standard library directory.
>>
>> Setting PATH like this avoids need to use either WSGIPythonHome or
>> WSGIPythonExecutable and so you should not set either of those
>> directives for this case.
>>
>> Indicate how that goes and can suggest some other things.
>>
>> Graham
>>
>> 2010/1/21 toinbis <[email protected]>:
>>
>> > Hi everyone!
>>
>> > Even though i compile mod_wsgi with "--with-python=/path/to/custom/
>> > python/executable", the system python executable is being used to run
>> > the wsgi app, not the custom one. Is there any setting i'm
>> > misconfiguring in httpd.conf or anywhere else?
>>
>> > If the the Django framework (python-django Ubuntu package) is not
>> > installed in the system python, the url, triggering the django wsgi
>> > app, ends up with Apache's internal error and `"ImportError: No module
>> > named django.core.handlers.wsgi"` message in apache's error logs. If
>> > django is installed in the system path, it ends up with django pretty
>> > error page:
>>
>> > ImportError at /
>>
>> > No module named djangosphinx.models
>>
>> > Request Method: GET
>> > Request URL: http://127.0.0.1:8001/djangoapp/
>> > Exception Type: ImportError
>> > Exception Value:
>>
>> > No module named djangosphinx.models
>>
>> > Exception Location:
>> > /home/toinbis/Desktop/programming/project/src/
>> > tsd/core/models.py in <module>, line 3
>> > Python Executable: /usr/bin/python
>>
>> > So clearly the problem is with using wrong python executable to run
>> > the wsgi app (djangosphinx is a module which is successfully imported
>> > with the zc.buildout custom generated python executable).
>>
>> > More background details:
>>
>> > Am deploying custom nginx + apache(mod_wsgi) + supervisor + mysql +
>> > python + django + php + phpmyadmin + wordpress setup using zc.buildout
>> > (http://buildout.org). Buildout.cfg details:
>>
>> > [apache]
>> > recipe = hexagonit.recipe.cmmi
>> > url =http://www.apache.lt/httpd/httpd-2.2.14.tar.gz
>> > keep-compile-dir = true
>> > configure-options = --enable-so
>>
>> > [mod_wsgi]
>> > recipe = hexagonit.recipe.cmmi
>> > url =http://modwsgi.googlecode.com/files/mod_wsgi-3.1.tar.gz
>> > keep-compile-dir = true
>> > configure-options = --with-python=${directories:buildout_root}/bin/
>> > python --with-apxs=${directories:buildout_root}/parts/apache/bin/apxs
>>
>> > The vhosts.conf file:
>>
>> > <snip>
>> > #=============================
>> > #Django_wsgi_app
>> > #=============================
>> > <VirtualHost *:8001>
>>
>> > <Directory /home/toinbis/Desktop/programming/project/runtime/
>> > htdocs/django_wsgi/>
>> > Order deny,allow
>> > Allow from all
>> > </Directory>
>>
>> > WSGIDaemonProcess tsd user=www-data group=www-data threads=25
>> > WSGIProcessGroup tsd
>>
>> > WSGIScriptAlias /djangoapp /home/toinbis/Desktop/programming/
>> > project/runtime/htdocs/django_wsgi/djproject.wsgi
>>
>> > LogLevel warn
>> > ErrorLog /home/toinbis/Desktop/programming/project/runtime/
>> > logs/apache_tsd_error.log
>> > CustomLog /home/toinbis/Desktop/programming/project/runtime/
>> > logs/apache_tsd_access.log combined
>>
>> > </VirtualHost>
>>
>> > </snip>
>>
>> > Tried adding different combinations of such lines in between
>> > <Virtualhost> </Virtualhost>:
>>
>> > WSGIPythonExecutable /home/toinbis/Desktop/programming/project/bin/
>> > python
>> > WSGIPythonHome /usr/bin
>> > #omelette dir has a symlink to all python modules installed with
>> > zc.buildout
>> > WSGIPythonPath /home/toinbis/Desktop/programming/project/parts/
>> > omelette
>>
>> > But usually that just caused apache to fail during the start,
>> > generating error(s):
>>
>> > [Thu Jan 21 10:05:37 2010] [debug] mod_wsgi.c(9921): mod_wsgi
>> > (pid=2299): Socket for 'tsd' is '/home/toinbis/Desktop/programming/
>> > project/parts/apache/logs/wsgi.2299.0.1.sock'.
>> > [Thu Jan 21 10:05:37 2010] [info] mod_wsgi (pid=2433): Starting
>> > process 'tsd' with threads=25.
>> > [Thu Jan 21 10:05:37 2010] [info] mod_wsgi (pid=2433): Initializing
>> > Python.
>> > <...> - similar lines :)
>> > [Thu Jan 21 10:05:37 2010] [info] mod_wsgi (pid=2438): Initializing
>> > Python.
>> > [Thu Jan 21 10:05:37 2010] [notice] Apache/2.2.14 (Unix) PHP/5.3.1
>> > mod_wsgi/3.1 Python/2.6.4 configured -- resuming normal operations
>> > [Thu Jan 21 10:05:37 2010] [info] Server built: Jan 17 2010 01:54:57
>> > [Thu Jan 21 10:05:37 2010] [debug] prefork.c(1013): AcceptMutex:
>> > sysvsem (default: sysvsem)
>> > [Thu Jan 21 10:05:37 2010] [info] mod_wsgi (pid=2435): Attach
>> > interpreter ''.
>> > [Thu Jan 21 10:05:37 2010] [info] mod_wsgi (pid=2434): Attach
>> > interpreter ''.
>> > [Thu Jan 21 10:05:38 2010] [info] mod_wsgi (pid=2436): Attach
>> > interpreter ''.
>> > <...> - similar lines :)
>> > [Thu Jan 21 10:11:09 2010] [info] mod_wsgi (pid=2436): Cleanup
>> > interpreter ''.
>> > [Thu Jan 21 10:11:09 2010] [info] mod_wsgi (pid=2434): Destroying
>> > interpreters.
>> > [Thu Jan 21 10:11:09 2010] [info] mod_wsgi (pid=2434): Cleanup
>> > interpreter ''.
>> > [Thu Jan 21 10:11:09 2010] [info] mod_wsgi (pid=2436): Terminating
>> > Python.
>> > [Thu Jan 21 10:11:09 2010] [info] mod_wsgi (pid=2434): Terminating
>> > Python.
>> > [Thu Jan 21 10:11:09 2010] [info] mod_wsgi (pid=2436): Python has
>> > shutdown.
>> > [Thu Jan 21 10:11:09 2010] [info] mod_wsgi (pid=2434): Python has
>> > shutdown.
>> > [Thu Jan 21 10:11:09 2010] [info] removed PID file /home/toinbis/
>> > Desktop/programming/project/parts/apache/logs/httpd.pid (pid=2299)
>> > [Thu Jan 21 10:11:09 2010] [notice] caught SIGTERM, shutting down
>> > [Thu Jan 21 10:24:33 2010] [debug] mod_wsgi.c(9921): mod_wsgi
>> > (pid=3926): Socket for 'tsd' is '/home/toinbis/Desktop/programming/
>> > project/parts/apache/logs/wsgi.3926.0.1.sock'.
>> > [Thu Jan 21 10:24:33 2010] [info] mod_wsgi (pid=3928): Starting
>> > process 'tsd' with threads=25.
>>
>> > djproject.wsgi (tried removing #!/home/.../python from the begining of
>> > the file, no help):
>>
>> > #!/home/toinbis/Desktop/programming/project/bin/python
>> > import os, sys
>>
>> > apache_configuration= os.path.dirname(__file__)
>> > sys.path.append(apache_configuration)
>> > #django project
>> > sys.path.append('/home/toinbis/Desktop/programming/project/src/
>> > tsd')
>> > #django source
>> > sys.path.append('/home/toinbis/Desktop/programming/project/parts/
>> > djangoapp/')
>>
>> > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>> > import django.core.handlers.wsgi
>> > application = django.core.handlers.wsgi.WSGIHandler()
>>
>> > Possibly-relevant settings in httpd.conf (these are the only two
>> > modules being loaded. Rest of the settings doesn't seem relevant to
>> > the given problem):
>>
>> > LoadModule php5_module modules/libphp5.so
>> > LoadModule wsgi_module modules/mod_wsgi.so
>>
>> > Thanks in advance for any ideas and suggestions how to make the custom
>> > python executable (which, itsefl, is just a wrapper script for system
>> > python, with several added python path dirs) run the mod_wsgi app!
--
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.