Reading Time: 3 minutes

In this article, we will be installing a simple Python app on a cPanel server utilizing WSGI or Web Server Gateway Interface.

Installing Python WSGI Applications on cPanel

Let’s begin by installing the packages and dependencies for Python 3.

yum install python3 python3-pip python3-devel python-virtualenv

Next, we’ll install the packages and dependencies for Passenger.

Note: Installing ea-ruby24-mod_passenger will disable the mod_userdir module.

yum install ea-ruby24-mod_passenger ea-apache24-mod_env

Now, we need to change directories back to the home directory for the cPanel account this application will reside on.

cd /home/thisisatest

Next, we’ll create a virtual environment using the following command:

virtualenv --python=python3 python_test

Now, change directories into the virtual environment and run the following command to activate it:

source bin/activate

In this example, we’ll be creating a sample Flask application to demonstrate how to run a Python application with Passenger. 

Let’s create the Flask file first.


Next, let's add the following info into the file:

from flask import Flask

app = Flask(__name__)

def index():
  return "<h1>Hello, world!</h1>"

Now, let’s create the Passenger WSGI file.


Next, add the following info into the file:

import sys, os

INTERP = "/home/thisisatest/python_test/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)

from python_test import app as application

The last step is to register this as an application inside of cPanel. Login to cPanel and navigate to the Software manager section, then click on Application Manager.


Next, enter the name for the application and click on Register Application.

wsgi app mamager

Now, under the Register an Application, we name the app, then choose the domain it will be run on, and then finally, enter the path to the application itself. In this case, the name will be python_test. The domain will be the account, and the path will be /home/thisisatest/python_test. We have also selected "Development" under the Deployment Mode.


Save this application by clicking on the Deploy button.

Now, we can load this application in a browser window by entering the URL where the app was created. That's all there is to it!


Get Started Today!

Are you looking to begin pushing your web apps to a staging or production environment and need a solid platform to build on? Look no further as Liquid Web has you covered! Check out our line of VPS or Cloud Dedicated servers today. We can get you on the right path to owning your own development servers today! As a side note, this would also be useful in a HIPAA compliant hosting solution.

Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions Team or an experienced Hosting Advisors today!

Avatar for John Long

About the Author: John Long

Latest Articles

Innovative armor — exploring ThreatDown’s impact on cyber defense

Read Article

Using a Cloudflare Argo Tunnel with load balancing

Read Article

Controlling PHP settings with a custom php.ini file

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article