How to Install a Python WSGI Application in cPanel

This guide explains how to install, configure, test, and register a Python WSGI web application in cPanel. It covers virtual environments, Passenger configuration, dependency installation, testing the app, and restarting it using restart.txt.

Python WSGIcPanel PythonPassenger Python

~2 min read · Updated Feb 21, 2026

1. Overview


This document explains how to install a Python™ WSGI web application from the command line. Python WSGI is a standardized interface that allows Python applications to run on web servers.


For more information, refer to the Python WSGI documentation and cPanel’s guide on using Python on AlmaLinux, Rocky Linux, Ubuntu, and CloudLinux 9 and later.


Warning: WebPros International, LLC does not develop or support Python WSGI applications. cPanel Technical Support cannot assist with these applications. You are responsible for any data loss.


2. Pre‑Installation Settings


Note: Perform all steps as a cPanel user unless otherwise specified. You may also use cPanel’s Terminal interface.


In this guide, pythonapp represents the application name.


Your hosting provider must install pip and the required EasyApache 4 packages.


2.1 Required Packages for CentOS 7, AlmaLinux 8, Rocky Linux 8


  • ea-ruby27-mod_passenger
  • ea-apache24-mod_env

Recommended: ea-ruby27-ruby-devel


2.2 Required Packages for AlmaLinux 9 / Rocky Linux 9


  • ea-apache24-mod-passenger
  • ea-apache24-mod_env

Passenger automatically uses the newest installed versions of Ruby, NodeJS, and Python.




3. Install a Python Application


3.1 Create the Application Directory


mkdir directoryname

3.2 Create a Virtual Environment


virtualenv --python=python3 directoryname

If virtualenv is missing:


pip install virtualenv

3.3 Activate the Virtual Environment


cd directoryname
source bin/activate

3.4 Create the WSGI File


Create passenger_wsgi.py with the following content:


import sys, os

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

from pythonapp import app as application

3.5 Install Dependencies


Create a requirements.txt file, then run:


pip install -r requirements.txt

Warning: Dependency versions must match your Python version.




4. Test the Application


Run the application:


python pythonapp.py

Expected output:


Hello, World!

In another terminal:


curl http://localhost:5000



5. Register the Application


Use:


cPanel » Home » Software » Application Manager


Access the application at:


http://example.com/pythonapp




6. Restart the Application


Create a restart.txt file inside the /tmp directory:


pythonapp/tmp/restart.txt

Passenger restarts the application when this file is touched.




Conclusion


This guide covers the complete process of installing, configuring, testing, and registering a Python WSGI application in cPanel. By following these steps, you can deploy Python applications efficiently using Passenger.


Written & researched by Dr. Shahin Siami

Related Articles

How to Restore Your cPanel Account: A Complete Guide for New System Administrators

This guide explains how new system administrators can restore a cPanel account using WHM, transfer accounts and configurations between servers, and enable diagnostic logging for transfer and restore operations. It covers essential concepts such as WHM vs. cPanel, root access, backup handling, SFTP uploads, transfer methods, and advanced debugging tools.

Continue

آموزش کامل انتقال تمام اکانت‌های cPanel از یک سرور به سرور دیگر

این مقاله نحوه انتقال همه اکانت‌های cPanel، تنظیمات سرویس‌ها، گواهی‌های SSL و IP اصلی سرور را از یک سرور قدیمی (Source) به یک سرور جدید (Target) توضیح می‌دهد. شامل نصب سرور جدید، انتقال تنظیمات، انتقال اکانت‌ها، تغییر IP، تنظیم DNS و نصب مجدد SSL است.

Continue

How to Migrate a WordPress® Installation to a cPanel & WHM Server

This guide explains how to migrate a WordPress installation from a macOS-hosted environment to a cPanel & WHM server. It covers exporting the database, uploading WordPress files, creating and importing a MySQL database, updating URLs, configuring wp-config.php, fixing broken links, and finalizing the migration.

Continue

How to Manually Transfer an Account Between Servers in cPanel & WHM

This article explains how to manually transfer a cPanel account between servers when the account is too large for WHM’s automated transfer tools. It covers creating temporary directories, compressing public_html and log files, securely transferring data with SCP, and restoring the files on the destination server.

Continue

How to Manually Migrate Horde Calendars and Contacts to Roundcube in cPanel & WHM

This article explains how to manually migrate Horde calendars and contacts to Roundcube in cPanel & WHM version 108 through 118. It covers exporting Horde data, placing it in the correct directories, and importing it into Roundcube using built‑in plugins or manual import tools.

Continue

How to Manually Migrate Accounts to cPanel & WHM from Unsupported Control Panels

This article explains how experienced system administrators can manually migrate accounts from unsupported third‑party control panels to cPanel & WHM. It covers pre‑migration steps, installation requirements, file and directory transfers, database restoration, SSL migration, and post‑migration tasks.

Continue