This guide provides a step-by-step walkthrough to deploy a Django project (with Tailwind CSS) [Django (with Tailwind, Bootstrap, or plain CSS/JS) on cPanel using the Python Setup App] on a cPanel-based hosting environment using the Python App Setup tool.
- Access to a hosting provider with cPanel that supports Python App Setup (e.g., ProtozoaHost)
- Your Django + Tailwind project (e.g., from GitHub)
- A local development environment with Python and Node.js (for Tailwind build)
- Basic understanding of terminal commands
- Django version: 3.x to 5.x
- Tailwind CSS is compiled locally (cPanel does not support Node.js)
Ensure your settings.py has:
import os
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')Use django-environ for .env:
import environ
env = environ.Env()
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))SECRET_KEY=your-secret-key
DEBUG=False
ALLOWED_HOSTS=yourdomain.com
DATABASE_URL=mysql://user:password@localhost/dbname
npm install
npx tailwindcss -i ./input.css -o ./output.css --minifyPut the final output.css into your static/ directory.
python manage.py collectstatic --noinputpip freeze > requirements.txtZip your project (excluding venv/, .git/, node_modules/).
- Go to File Manager in cPanel
- Navigate to
/home/youruser/project-root/ - Upload and extract your project
- Ensure
manage.pyis in the root of the folder
- Open Setup Python App in cPanel
- Click Create Application
- Python version: 3.12+
- Application root:
blog-application(or your folder name) - Application startup file:
passenger_wsgi.py - Application entry point:
application
When you first create the Python App, cPanel auto-generates folders such as
public/,tmp/, and a placeholderpassenger_wsgi.py. You can delete those later or leave them, but replace thepassenger_wsgi.pywith your own.
Inside your app root, create passenger_wsgi.py:
import sys
import os
project_home = '/home/youruser/blog-application'
if project_home not in sys.path:
sys.path.insert(0, project_home)
os.environ['DJANGO_SETTINGS_MODULE'] = 'yourproject.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()source /home/youruser/virtualenv/blog-application/3.12/bin/activate
cd /home/youruser/blog-applicationpip install -r requirements.txtIf using MySQL:
pip install mysql-connector-python❌ Common Error:
ModuleNotFoundError: No module named 'MySQLdb'
- Fix: Use
mysql-connector-pythonand change your ENGINE tomysql.connector.django
python manage.py migrate❌ Possible Error:
ImproperlyConfigured: Set the SECRET_KEY environment variable
- Fix: Ensure
.envfile is in your root directory and readable by Django
python manage.py createsuperuserpython manage.py collectstatic --noinput🌐 Step 6: Configure Static Files with WhiteNoise [https://whitenoise.readthedocs.io/en/latest/]
pip install whitenoiseMIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
...
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'Go to Python App Setup > Click RESTART.
Visit: https://yourdomain.com
- If you see the Django site styled properly — ✅ Success!
- If static files still fail, ensure
.env, static file path, and WhiteNoise config are in place
| Problem | Fix |
|---|---|
| 500 Internal Server Error | Check error logs in cPanel Metrics or terminal logs |
| CSS Not Loading | Use WhiteNoise middleware and collectstatic output |
SECRET_KEY error |
Ensure .env file exists and is properly formatted |
MySQLdb error |
Use mysql-connector-python and update ENGINE |
ModuleNotFoundError |
pip install missing package |
404 on /static/ files |
Use WhiteNoise or check Apache .htaccess (last resort) |
Your Django app with Tailwind CSS is now live on cPanel, fully backed by a MySQL database, secured .env config, and served static assets reliably via WhiteNoise.
If you need bonus features like email, domain redirects etc. — build from here!