0

I'm trying to run a Turbogears2 application on WSGI mod under Apache 2.4.25:

My virtualhost seems to be ok: /etc/apache2/sites-available/site.conf

<VirtualHost *:80>

        ServerName www.site.com
        #ServerAdmin "Charlie ROOT"

        # ISTC is the only application on this server, thus will be served from /
        WSGIScriptAlias / /usr/local/lib/python2.7/dist-packages/site.egg/apache/app.wsgi

        # Have apache serving static content directly (not through WSGI)
        Alias /img /usr/local/lib/python2.7/dist-packages/site.egg/ehp/public/img
        Alias /css /usr/local/lib/python2.7/dist-packages/site.egg/ehp/public/css
        Alias /js /usr/local/lib/python2.7/dist-packages/site.egg/ehp/public/js

        # Execution is "daemon mode"
        WSGIProcessGroup www.site.com
        WSGIDaemonProcess www.site.com user=www-data group=www-data threads=4 python-path=/usr/local/lib/python2.7/dist-packages

My file /etc/apache2/apache.conf seems to cointain rigth policy too :

<Directory / >
        Require all granted
</Directory>

So this give me an Internal Server Error ...

I checked Apache var/log/error.log :

mod_wsgi (pid=15064): Target WSGI script '/usr/local/lib/python2.7/dist-packages/site.egg/apache/app.wsgi' cannot be loaded as Python module

mod_wsgi (pid=15064): Exception occurred processing WSGI script '/usr/local/lib/python2.7/dist-packages/site.egg/apache/app.wsgi'.

Traceback (most recent call last):
.
................
........................................
.......................................
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 849, in resolve
         raise DistributionNotFound(req, requirers)
DistributionNotFound: The 'who_ldap>=3.2.2' distribution was not found and is required by site

I just reinstall "who_ldap-3.2.2.tar.gz" module successfully so i don't understand ... Is it a python path problem ? How to correct it ?

Dimitri
  • 33
  • 8
  • You should need ``python-path=/usr/local/lib/python2.7/dist-packages``. If you find it is needed, then mod_wsgi may be compiled for a different Python version than what you want to use. – Graham Dumpleton Oct 10 '17 at 19:48
  • Yes, I already specified my 'python-path=/usr/local/lib/python2.7/dist-packages' in Apache virtualhost. Is there another file where I must to specify ? – Dimitri Oct 11 '17 at 07:54
  • Whoops, that should have read 'should not need'. Python should look in that location by default anyway. So if taking that out causes things to not work at all, then mod_wsgi is likely not compiled for the version of Python you are trying to use. – Graham Dumpleton Oct 11 '17 at 09:48
  • Ah ok, I removed python-path and there is no difference, however this is written in the documentation, part 7 (to let python-path): http://turbogears.readthedocs.io/en/latest/cookbook/deploy/mod_wsgi.html What does that means that mod_wsgi is likely not compiled for the version of Python I'm trying to use ? How can I correct it ? – Dimitri Oct 13 '17 at 12:19
  • Work out what version of Python it is compiled for and which it is using. See http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#python-installation-in-use and http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#python-shared-library – Graham Dumpleton Oct 13 '17 at 20:24
  • M python version is : Python 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118] on linux2 And I can't use ldd commande, I'm not using module ‘mod_wsgi.so’. I'm using a traditional Apache module installed into an existing Apache installation. – Dimitri Oct 16 '17 at 12:46
  • When using a traditional Apache module in an existing Apache installation, there will still be a mod_wsgi.so file. It will be in the Apache modules directory. The mod_wsgi module doesn't support static linking into Apache and no Linux distro uses static link of Apache modules. – Graham Dumpleton Oct 16 '17 at 20:06
  • Ok thank you very much ! I got this result after checked python shared lybrary, so it seems to be ok. `/var/www/site# ldd /usr/lib/apache2/modules/mod_wsgi.so ... libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007f19cc672000) ... /var/www/site# unset LD_LIBRARY_PATH /var/www/site# ldd /usr/lib/apache2/modules/mod_wsgi.so ... libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007f0a27071000)` How to execute Python installation in use now ? with the function `def application(environ, start_response):` – Dimitri Oct 17 '17 at 09:14
  • From the command line Python, if you do ``import who_ldap; print(who_ldap.__file__)``, what do you get? – Graham Dumpleton Oct 17 '17 at 09:29
  • I got this : `>>> import who_ldap >>> print(who_ldap.__file__) /usr/local/lib/python2.7/dist-packages/who_ldap-3.2.2-py2.7.egg/who_ldap/__init__.pyc >>>` – Dimitri Oct 17 '17 at 09:48
  • All I can suggest is you compare ``sys.path`` in command line Python with what ``sys,path`` is in the WSGI application when running under mod_wsgi. Also make sure that permissions on installed packages under ``/usr/local/lib/python2.7/dist-packages`` are such that they are readable by others and haven't somehow been installed with strange file system permissions. – Graham Dumpleton Oct 17 '17 at 10:06
  • My sys.path contains a lot of path, LDAP is : `/usr/local/lib/python2.7/dist-packages/ldap3-1.4.0-py2.7.eg‌​g` While the error in apache logs are : `File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 640, in find_egg_entry_point pkg_resources.require(self.spec) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py"‌​, line 963, in require needed = self.resolve(parse_requirements(requirements)) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py"‌​, line 849, in resolve raise DistributionNotFound(req, requirers) Distrib.. who_ldap not found` – Dimitri Oct 17 '17 at 12:59
  • Next thing to try would be to ``pip uninstall`` the ``who_ldap`` package. Do that multiple times until it says it can't be removed. There may be multiple versions sitting there which is confusing things. Then install the desired version again. – Graham Dumpleton Oct 17 '17 at 19:50

0 Answers0