How to Check mod_wsgi version in Apache

check mod_wsgi version apache

mod_wsgi is a useful Apache module that allows you to host Python applications in Apache web server. It enables you to run python applications built using Django, Pylon, Flask and other popular frameworks via Apache server. However, it is important to use the right version of mod_wsgi with Apache. Here’s how to check mod_wsgi version in Apache.


How to Check mod_wsgi version in Apache

Here are the steps to check mod_wsgi version in Apache. Unfortunately, there is no direct command to print out mod_wsgi version. We have to print the version from inside our python script that we run inside Apache.

Before you proceed, please ensure you have installed mod_wsgi in Apache. Here are the steps.


1. Verify module

If you have already installed mod_wsgi in Apache, let us verify that it is enabled. Open a terminal and run the command


This will list all the enabled modules in your Apache server. Look for the line with “mod_wsgi” in it.

On Debian:

$ /usr/sbin/apache2 -l


Most CentOS/RHEL/Fedora/GNU/Linux distros:

$ /usr/sbin/httpd -l


2. Create test file

We will create a simple python script for displaying mod_wsgi version. In the script, we will import mod_wsgi and print its version number

Create a blank new python script

$ sudo vi /var/www/html/


Paste the following lines in it. Please ensure they are indented properly, to avoid error messages.

import mod_wsgi

def application(environ,start_response):
 status = '200 OK'
 html = '<html>\n' \
  '<body>\n' \
  mod_wsgi.version+'\n' \
  '</body>\n' \
 response_header = [('Content-type','text/html')]
 return [html]

Save and close the file


Next, we create a mod_wsgi config file for the above script to be served via Apache. Open mod_wsgi’s config file in a text editor.

$ sudo nano /etc/apache2/conf-available/mod-wsgi.conf


Add the following line:

WSGIScriptAlias /test_wsgi /var/www/html/

Save and close the config file


Run the following commands to enable mod_wsgi

$ sudo a2enconf mod-wsgi
$ sudo systemctl restart apache2


3. Get mod_wsgi version in Apache

Open your web browser and go to http://your_server_ip/test_wsgi. Replace your_server_ip with your server’s ip or domain name.


The browser page will display mod_wsgi version name.



About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!