The Setup Python App tool in cPanel (provided by CloudLinux) creates a Python virtual environment for your project and serves it through Phusion Passenger using WSGI. It is a simple way to host a Flask API, a Django site or a small dashboard next to your other websites.
Before you start
- Your project with a
requirements.txt. - A domain or subdomain for the app, e.g.
api.example.com. See create a subdomain. - Terminal or SSH access to run pip and Django commands.
Create the application
- Open cPanel → Software → Setup Python App and click Create Application.
- Python version: choose the version your project uses (for example 3.11 or 3.12).
- Application root: e.g.
apps/myapi, outsidepublic_html. - Application URL: the domain and optional path.
- Application startup file:
passenger_wsgi.py(default). - Application Entry point:
application(default). - Add Environment variables such as
DJANGO_SETTINGS_MODULEorSECRET_KEY. - Click Create.
Upload code and install requirements
- Upload your project into the application root (File Manager, FTP or Git).
- Copy the virtual environment command shown at the top of the app page, e.g.
source /home/user/virtualenv/apps/myapi/3.12/bin/activate && cd /home/user/apps/myapi. - Paste it in Terminal and run
pip install -r requirements.txt. - Alternatively, enter
requirements.txtunder Configuration files in the app settings and click Run Pip Install.
Connect the WSGI entry point
Edit passenger_wsgi.py so it imports your app as application.
Flask (app object app in main.py):
from main import app as applicationDjango (project named mysite):
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()Click Restart on the app page after each change.
Django: static files and database
- Set
ALLOWED_HOSTS = ['api.example.com']andDEBUG = False. - Set
STATIC_ROOTto a folder inside the domain's document root, e.g./home/user/api.example.com/static, then runpython manage.py collectstatic. - Use a cPanel MySQL database (create one) with host
localhostand themysqlclientorPyMySQLpackage, then runpython manage.py migrate.
Note: Passenger starts the app on demand. Long-running background workers (Celery, schedulers) are not suitable for shared hosting; use cron jobs for periodic tasks.
Troubleshooting
- "Something went wrong" / 500: check
stderr.login the application root, or set a Passenger log file in the app settings. Missing modules mean pip ran in the wrong environment. - Static files missing: STATIC_ROOT is outside the document root, or collectstatic was not run.
- Changes not visible: click Restart or
touch tmp/restart.txt.
