How to get the version of wsgi_mod which apache used?
Asked Answered
P

6

25

I am using ubuntu 12.041 and installed apache through apt-get.

I don't know what version of mod_wsgi i am using albeit I google about it. All I found is you can use apachctl to restart you apache and you would get something like "Apache/2.2.2 (Unix) mod_wsgi/1.0 Python/2.3 configured". But this's not happened to me.

Is there any way to know what version I am using ? Thanks.

President answered 19/4, 2013 at 4:32 Comment(0)
H
14

In your WSGI application look at the value of mod_wsgi.version in the WSGI environ dictionary. That or import mod_wsgi module in a WSGI application running under mod_wsgi (not command line Python) and print out mod_wsgi.version from that module.

Hernadez answered 19/4, 2013 at 5:37 Comment(2)
some... code? or a folder? or a pointer to something that made this an easy 1,2,3 process would be really really useful.Leeds
Just add import mod_wsgi and logsomewhere(mod_wsgi.version) to your code. As mentioned, you need to run the code within wsgi/apache. Not inside Django Runserver. Or you add modwsgi.version to a template Context and show it on some system information page of your appliaction.Edith
M
20

If you restart Apache and inspect the log:

sudo apachectl -k restart
tail -n 5 /var/log/apache2/error.log

... you should see the version:

[Fri Jun 05 15:13:46.546029 2015] [mpm_prefork:notice] [pid 2245] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.9 mod_wsgi/3.4 Python/3.4.0 configured -- resuming normal operations

Magnifico answered 5/6, 2015 at 18:0 Comment(2)
I believe the information in that line may be able to be excluded in part if Apache is configured a certain way. So don't necessarily rely on the information about mod_wsgi and Python appearing.Hernadez
You can look at the existing log without restarting: grep mod_wsgi /var/log/apache2/error.logMalka
H
14

In your WSGI application look at the value of mod_wsgi.version in the WSGI environ dictionary. That or import mod_wsgi module in a WSGI application running under mod_wsgi (not command line Python) and print out mod_wsgi.version from that module.

Hernadez answered 19/4, 2013 at 5:37 Comment(2)
some... code? or a folder? or a pointer to something that made this an easy 1,2,3 process would be really really useful.Leeds
Just add import mod_wsgi and logsomewhere(mod_wsgi.version) to your code. As mentioned, you need to run the code within wsgi/apache. Not inside Django Runserver. Or you add modwsgi.version to a template Context and show it on some system information page of your appliaction.Edith
L
13

I use this

dpkg -l | grep wsgi

I don't know what it is doing, but it is a version?

As an aside that is probably not right, the version i have -

libapache2-mod-wsgi  (on ubuntu 10.04)

is not python 3.x compliant. How I know that is a mystery - some random web forum. Also, how you'd actually work out which version is in the libapache2 version is beyond my ken.

But, ah, that unix script above will get the version for you. You're on your own after that, sailor.

Leeds answered 8/8, 2014 at 11:58 Comment(1)
For more detail on mod_wsgi version of distro packaged version, from scribbled notes I have, you can run apt-cache policy libapache2-mod-wsgi. A Python 3 version will have 'py3' as part of the package name on Ubuntu systems.Hernadez
C
9

move to apache modules directory where mod_wsgi.so is.

run the following commands.

$ strings mod_wsgi.so | grep -w -A 1 "wsgi_init"
wsgi_init
4.5.7   

Note it may be necessary to use -A with more than 1 line displayed after the occurrence of wsgi_init. For example with mod_wsgi version 2.7.5 you need -A 2 to see the version number:

$ strings mod_wsgi.so | grep -w -A 2 "wsgi_init"
wsgi_init
mod_wsgi/%s
2.7.5
Congenital answered 8/4, 2017 at 18:41 Comment(2)
I think I am using mod_wsgi for Python 2.7 or 3.4.3 (trying to figure it out) and following your command did not do the trick for me. I got these two lines for output: wsgi_init and mod_wsgi/%s. There were no leading or trailing spaces in the output, only a newline separator.Machellemachete
I had the same issue. I changed -A 1 to -A 5 to get more lines after wsgi_init printed. I got wsgi_init mod_wsgi/%s 2.7.5 %s.%d.%d.%d.sock %s.%d.%d.%d.lock sysvsemEnow
S
4

A side question was about the version of Python used by mod_wsgi. For that just inspect mod_wsgi.so modules with ldd:

➜  / cd usr/lib/apache2/modules 
➜  modules ldd mod_wsgi.so
        linux-vdso.so.1 =>  (0x00007ffcaabf3000)
        libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007f4e29c62000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4e29a45000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4e2967b000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f4e29461000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4e2925d000)
        libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f4e2905a000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4e28d51000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4e2a423000)
➜  modules 

In my case, it is clearly compiled with python2.7.

Saree answered 15/4, 2018 at 15:17 Comment(0)
A
0

This is very old but I'm not seeing the answer i found so:

yum list installed '*mod_wsgi*'

or better yet

yum list '*mod_wsgi*'

to see what you have installed as well as available (perhaps) later versions.

Afebrile answered 22/12, 2019 at 1:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.