SakuraHost cPanel hosting runs Python apps through Application Manager and Phusion Passenger (WSGI). This guide deploys a Django project on it. Our cPanel servers currently provide Python 3.9, so use Django 4.2 LTS (Django 5 and newer need Python 3.10+; if you need them, use a VPS instead).

Before you start: your hosting service must be Active, your domain must point to us, and you need either cPanel Terminal or SSH to create the virtual environment. If Terminal isn't available on your plan, contact support and we'll enable it or help with the setup.

1. Upload your project

Put your Django project (the folder that contains manage.py) in your home directory, outside public_html, for example /home/USERNAME/myproject. Use Git Version Control, File Manager or SFTP.

2. Create a virtual environment and install packages

python3 -m venv ~/venv/myproject
source ~/venv/myproject/bin/activate
pip install --upgrade pip
pip install "Django>=4.2,<5" -r ~/myproject/requirements.txt

Pin Django>=4.2,<5 in your requirements.txt too. For MySQL, use pymysql (pure Python, no compiling) and add import pymysql; pymysql.install_as_MySQLdb() at the top of your settings.py. SQLite also works for small apps.

3. Register the app in cPanel

Open Application Manager (cPanel > Software) and click Register Application:

  • Application Name — e.g. myproject
  • Deployment Domain — your domain
  • Base Application URL — /
  • Application Path — myproject (the folder from Step 1)
  • Deployment Environment — Production

Click Deploy. Do not use "Site Software" or "WordPress Management"; they can't run Django.

4. Add passenger_wsgi.py

Create /home/USERNAME/myproject/passenger_wsgi.py (replace USERNAME and myproject; the settings module is the folder that contains your settings.py):

import os, sys

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

sys.path.insert(0, os.path.dirname(__file__))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

5. Production settings

DEBUG = False
ALLOWED_HOSTS = ["yourdomain.com", "www.yourdomain.com"]
STATIC_URL = "/static/"
STATIC_ROOT = "/home/USERNAME/public_html/static"

If your domain's document root is not public_html (addon domain), use that domain's folder instead. Never leave DEBUG = True or your SECRET_KEY in a public repository.

6. Migrate, collect static files, restart

source ~/venv/myproject/bin/activate
cd ~/myproject
python manage.py migrate
python manage.py collectstatic --noinput
mkdir -p tmp && touch tmp/restart.txt

You can also click Restart next to your app in Application Manager. Do this after every code change.

7. If it doesn't load

  • Raw "Index of /" page: the Application Path doesn't match where passenger_wsgi.py is, or the app isn't Enabled in Application Manager.
  • 500 error: check ALLOWED_HOSTS, the DJANGO_SETTINGS_MODULE name, and that the venv path in passenger_wsgi.py is correct. Run python manage.py check --deploy inside the venv.
  • Static files / CSS missing: re-run collectstatic and check STATIC_ROOT points inside your domain's document root.
  • "requires Python 3.10" or similar: your Django version is too new for our servers. Use Django 4.2 LTS or a VPS.

Still stuck? Contact SakuraHost Support with your domain and cPanel username.

Kwa Kiswahili (muhtasari)

  1. Pakia project yako ya Django nje ya public_html (mfano ~/myproject).
  2. Tengeneza virtualenv na uweke Django 4.2 LTS (seva zetu zina Python 3.9).
  3. Sajili app kwenye Application Manager ndani ya cPanel (Application Path = folda ya project).
  4. Ongeza passenger_wsgi.py kama ilivyo hapo juu, weka ALLOWED_HOSTS na STATIC_ROOT.
  5. Endesha migrate na collectstatic, kisha bonyeza Restart.

Ukikwama, tutumie domain yako na jina la cPanel, tutakusaidia.

Was this answer helpful? 0 Users Found This Useful (0 Votes)