With CloudLinux's Python Selector you can run Python web apps such as Flask, Django or FastAPI (through a WSGI adapter) on cPanel hosting. Each app gets its own virtual environment and is served on your domain by Passenger.
Before you start
- cPanel access with Setup Python App in cPanel → Software.
- Your app's code and a
requirements.txt. - A domain or subdomain for the app.
Create the application
- Go to cPanel → Software → Setup Python App.
- Click Create Application.
- Python version: choose the version your app needs, for example 3.11 or 3.12.
- Application root: a folder outside
public_html, such asmyflask. - Application URL: choose the domain and optional path.
- Application startup file:
passenger_wsgi.py. - Application entry point:
application. - Click Create. cPanel creates the folder, a virtual environment and a sample
passenger_wsgi.py.
Upload your code
Upload your project into the application root with File Manager, FTP or Git. Keep the generated passenger_wsgi.py and edit it to load your app.
Flask
from app import app as applicationThis assumes your Flask object is named app in app.py.
Django
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_wsgi_application()Install requirements
- On the app page, enter
requirements.txtin the Configuration files box, click Add, then Run Pip Install. - Or copy the
source …/activatecommand from the top of the app page, run it in cPanel → Advanced → Terminal, then runpip install -r requirements.txt.
Django extras
- Add your domain to
ALLOWED_HOSTS. - Run
python manage.py migrateandpython manage.py collectstaticinside the virtual environment. - Serve static files from a folder in
public_htmland setSTATIC_ROOTto it. - Use a MySQL database created in cPanel (see MySQL Database Wizard) with the
mysqlclientorPyMySQLdriver.
Restart and test
Click Restart on the app page after every change, then open the application URL. Errors are written to stderr.log in the application root.
Troubleshooting
"We're sorry, but something went wrong"
Passenger could not load the app. Read stderr.log; usually an import error or a missing package.
ModuleNotFoundError
Packages were installed outside the virtual environment. Activate it first, then reinstall.
pip install is killed
Heavy packages can exceed memory limits during build. Install one at a time and check Resource Usage.
Note: Long-running workers (Celery, schedulers) are not suited to shared hosting. Use cron jobs for scheduled tasks, or a VPS for workers.
Similar steps for JavaScript apps are in setting up a Node.js app.
Frequently asked questions
Can I run FastAPI?
Passenger uses WSGI, while FastAPI is ASGI. Wrap it with an ASGI-to-WSGI adapter such as a2wsgi, or use Flask or Django for shared hosting.
Can I change the Python version later?
Yes, but the virtual environment is rebuilt, so run pip install again afterwards.
Where should I store secrets?
Add them as environment variables on the app page instead of committing them in code, then read them with os.environ.
