The mod_wsgi is an Apache module used to serve Python scripts over HTTP. This tutorial helps you to how to install the Apache mod_wsgi module on Debian 10 Linux system.

Prerequisites

Login to your Debian 10 system terminal with the root or sudo privileged account.

Step 1 – Install Python

You must have installed required Python version on your system. For the Ubuntu systems, you can use apt package manager to install Python on your system.

Step 2 – Install Apache Mod_wsgi Module

Next, you need to install Apache web server including Apache utility package and mod_wsgi Python module on your system. To install these packages run the following commands. After installation, restart Apache service to reload all modules.

Step 3 – Configure Apache with WSGI Module

Now, create a sample python script to serve with mod_wsgi Apache module. Run the following commands to create a Python script and edit in your favorite text editor: Add the below python script to file:

Save your Python script and close file. Next, configure Apache server to serve this file over the HTTP protocol. Let’s create a configuration file to serve the wsgi_test_script.py script with the directory URL. Add the following content: After completing the above steps enable mod-wsgi configuration and restart Apache service.

Step 4 – Testing Setup

The Python script is ready to serve over Apache. You can test the script by accessing the following URL in a web browser. Make sure to change SERVER_IP_OR_DOMAIN with actual server IP or domain name pointed to the IP. See below screenshot:

Conclusion

In this tutorial, you have learned to deploy Python script over Apache web server using mod_wsgi module on Ubuntu system.

How to Install Apache with Python mod wsgi on Debian 10   TecAdmin - 63