The mod_wsgi
is an Apache module that provides a WSGI compliant interface and serves for hosting Python based web applications under Apache (for example Django).
To find out which version of mod_wsgi is installed or compiled, it is required to create a simple WSGI application.
From the following article you will learn how to create and run on Apache a simple WSGI application that prints the version of mod_wsgi.
Cool Tip: Check whatever WSGI module is enabled or not! Read how to →
mod_wsgi – Get The Version
Create a directory for WSGI application:
# mkdir -p /usr/local/www/wsgi-scripts
Here is a simple WSGI application script that prints the version of mod_wsgi:
def application(environ, start_response): status = '200 OK' output = str(environ['mod_wsgi.version']) response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
Save it to /usr/local/www/wsgi-scripts/version.wsgi
file.
Create a virtual host config in Apache:
<VirtualHost *:80> WSGIScriptAlias /version /usr/local/www/wsgi-scripts/version.wsgi <Directory /usr/local/www/wsgi-scripts> Require all granted # Apache 2.4+ Order allow,deny Allow from all </Directory> </VirtualHost>
And, depending on your distribution, save it to /etc/httpd/conf.d/example.com.conf
if you use CentOS, RHEL etc., or to /etc/apache2/conf.d/example.com.conf
for Debian, Ubuntu etc.
Cool Tip: New to Python and WSGI? Create your first simple ‘Hello World’ application with mod_wsgi and Apache! Become a real developer →
Execute one of the below commands, to reload Apache and apply modifications.
On CentOS, RHEL etc.:# service httpd reload
On Debian, Ubuntu etc.:
# service apache2 reload
Use curl
to run your WSGI application directly from the web-server’s command line and print the version of mod_wsgi:
# curl http://localhost/version (3, 5)