Mod-pyton on apache2 in Debian 9

Discussion in 'Server Operation' started by xstation, Jun 10, 2020.

  1. xstation

    xstation New Member

    I have been told not to use mod- python anymore but to use mod-wsgi
    I am not sure if this mod is compatible with a python programme written in 2010 here
    pyanon.sourceforge.net?

    xstation
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Try it and see?
     
  3. nhybgtvfr

    nhybgtvfr Active Member

    as @Taleman says, try it, it's the easiest way to find out.
    and if mod-wsgi is the modern option to use, then it's not a case of is it compatible with the old 2010 code, but is the old 2010 code compatible with mod-wsgi and the latest releases of python. I have no idea what's been deprecated, how syntax may have changed etc.
    but if the old code doesn't work as is, you have access to all the source code, you can update it to be compatible, that's the beauty of open source code, if it doesn't work for you, you can fix it. (assuming you can code, otherwise you can pay ;) / bribe :rolleyes: / blackmail :eek: someone to fix it for you.)
     
  4. xstation

    xstation New Member

    well yes thats true or what i could do which sounds strange is if you look at the error i am getting when i use mod-python


    Sun Jun 07 20:09:40.067593 2020] [:error] [pid 4892:tid 140605712928832] python_init: Python version mismatch, expected '2.7.5+', found '2.7.13'.

    take 2.7.13 out put 2.7.5+ in:)
     
  5. nhybgtvfr

    nhybgtvfr Active Member

    well, a 1 minute google search found several people have the same issue, albeit with different version numbers, and they all seem to have solved it with:
    Code:
    $ apt-get remove libapache2-mod-python libapache2-mod-wsgi 
    $ apt-get build-dep libapache2-mod-python libapache2-mod-wsgi 
    
     
  6. xstation

    xstation New Member

    thanks
    getting
    E: Unable to find a source package for libapache2-mod-python
     
  7. nhybgtvfr

    nhybgtvfr Active Member

    dunno, ubuntu 18.04 definitely has it, looks like Debian stretch should have it by default according to packages.debian.org.

    maybe you've changed the repo apt looks at in /etc/apt/sources.list? or maybe some of the archives are commented out in there.
     
  8. xstation

    xstation New Member

    i manged to install as suggested

    but after applying the lines in apache2 default which were
    <Directory /var/www/py>
    AddHandler mod_python .py
    PythonHandler hello
    PythonDebug On
    </Directory>

    I Restarted apache2 server and got this error

    [email protected]:~# systemctl restart apache2
    Job for apache2.service failed because the control process exited with error code.
    See "systemctl status apache2.service" and "journalctl -xe" for details.
    [email protected]:~# systemctl start apache2.service
    Job for apache2.service failed because the control process exited with error code.
    See "systemctl status apache2.service" and "journalctl -xe" for details.
    i then ran test

    [email protected]:~# apache2ctl configtest
    apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/python.load: Cannot load /usr/lib/apache2/modules/mod_python.so into server: /usr/lib/apache2/modules/mod_python.so: cannot open shared object file: No such file or directory
    Action 'configtest' failed.
    The Apache error log may have more information.

    so what i am thinking of doing next is
    echo "LoadModule python_module /usr/lib/apache2/modules/mod_python.so" > /etc/apache2/mods-available/python.load
    ln -s ../mods-available/python.load etc/apache2/mods-enabled/python.load
     
  9. xstation

    xstation New Member

    Well that did not work l got:
    ln: failed to create symbolic link '/etc/apache2/mods-enabled/python.load' : File exists
     
  10. nhybgtvfr

    nhybgtvfr Active Member

    the problem isn't the python.load file, it's mod_python.so

    does /usr/lib/apache2/modules/mod_python.so exist?

    if it's not there, you could try 'updatedb; locate mod_python.so' or 'find / -name "mod_python.so" see if it exists somewhere else.
     
  11. xstation

    xstation New Member

    ok its not there or anywhere else
    strange i did run
    $ apt-get build-dep libapache2-mod-python libapache2-mod-wsgi

    and that was ok
     
  12. nhybgtvfr

    nhybgtvfr Active Member

    dunno, if the modules there and enabled in /etc/apache2/mods-enabled then the other file should exist somewhere.

    could be getting into the realms of downloading the source and compiling it, which is where I bow out, that's something I actively try to avoid.

    if it can find the libapache2-mod-python module in the repo's now, perhaps uninstalling and purging, and then re-installing it...
    if this is a live active server, i'd suggest taking backups of the system first though.
     
  13. xstation

    xstation New Member

     

Share This Page