Deploy a Django (Python) app in cPanel
Updated 27 Nov 2026
Our hosting plans can run Python apps, including Django, through cPanel's Setup Python App.
1. Create the Python application
- In cPanel open Setup Python App › Create Application.
- Python version: the newest your project supports.
- Application root: a folder in your home directory, for example
myapp. - Application URL: your domain, or a path such as
yourdomain.co.tz/app. - Application startup file:
passenger_wsgi.py. Application Entry point:application. - Press Create.
At the top, cPanel shows a command to enter the virtual environment, like:
source /home/username/virtualenv/myapp/3.x/bin/activate && cd /home/username/myapp
Copy it.
2. Upload your project
Upload your Django project into the application root (~/myapp) with File Manager (upload a ZIP, then Extract), FTP, or git clone in the Terminal. manage.py should be directly inside myapp.
3. Install the requirements
Open cPanel Terminal, paste the command from step 1, then:
pip install -r requirements.txt
(or pip install django for a new project).
4. Point passenger_wsgi.py at Django
In File Manager, edit ~/myapp/passenger_wsgi.py so it contains only:
import os, sys
sys.path.insert(0, os.path.dirname(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = 'yourproject.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Change yourproject to the folder that holds your settings.py.
5. Settings for production
In settings.py:
DEBUG = False
ALLOWED_HOSTS = ['yourdomain.co.tz', 'www.yourdomain.co.tz']
STATIC_ROOT = BASE_DIR / 'static'
Keep secrets such as SECRET_KEY and database passwords in environment variables (Setup Python App › Environment variables) or a .env file, not in the code.
MySQL instead of SQLite: create the database and user in cPanel (they start with your cPanel username and _: see Create a MySQL database), pip install mysqlclient (or pymysql), and set HOST to localhost.
6. Migrate and collect static files
In the Terminal (inside the virtual environment):
python manage.py migrate
python manage.py collectstatic
7. Restart
Back in Setup Python App, press Restart for your app. Restart after every change to code or settings. Then open your domain.
Problems
| Problem | Fix |
|---|---|
ModuleNotFoundError |
Enter the virtual environment and run pip install -r requirements.txt again; restart. |
| CSS and images missing | Run collectstatic; check STATIC_ROOT; make sure STATIC_URL matches. |
DisallowedHost |
Add the domain to ALLOWED_HOSTS. |
| 500 error | Read stderr.log in the app folder and the logs in ~/logs. Temporarily set DEBUG = True to see the error, then set it back. |
Need more control (Celery, websockets, background workers)? Use a Cloud VPS.
Kwa Kiswahili
Kwenye cPanel › Setup Python App › Create Application (startup file passenger_wsgi.py, entry point application). Pakia mradi, ingia kwenye virtual environment kwenye Terminal, pip install -r requirements.txt, rekebisha passenger_wsgi.py, kisha migrate na collectstatic, na bonyeza Restart.
Still need help? Open a ticket and we will reply.