Knowledgebase

Quick and Easy Django Project Deployment in cPanel | Quick Guide | Prabhu Host Print

  • 0

At Prabhu Host, deploying Django projects on your hosting account is now simple and beginner-friendly. Whether you're a developer or experimenting with your first Python web app, our cPanel interface and Python App installer make it easy to get started.

 This guide is for users on Cloud Hosting, Reseller Hosting, or VPS with cPanel + CloudLinux.

Step 1: Prepare Your Django Project Locally

Before uploading your project, make sure you:

  • Have a working Django project (manage.py, settings.py, etc.)

  • Use a virtual environment locally (recommended)

  • Include a requirements.txt file with all dependencies:

     
    pip freeze > requirements.txt

Step 2: Upload Your Project to cPanel

  1. Login to cPanel.

  2. Open File Manager and go to your desired folder (e.g., public_html/django).

  3. Upload your Django project files and folders (excluding your local virtual environment).

  4. Ensure your project structure looks like:

     
    /home/username/django_project/ ├── manage.py ├── myapp/ ├── django_project/ ├── requirements.txt

 Step 3: Set Up the Python Application

  1. In cPanel, go to Software > Setup Python App.

  2. Click Create Application.

  3. Fill in the details:

    • Python version: Choose Python 3.9+ (depending on availability).

    • Application Root: The directory where you uploaded your project (django_project).

    • Application URL: Optional — where it will be accessed.

    • Application startup file: passenger_wsgi.py (you’ll create this file below).

  4. Click Create.

Step 4: Configure WSGI File

  1. In the same application folder (e.g., django_project/), create a file named:

     
    passenger_wsgi.py
  2. Edit it and paste:

     
    import sys import os # Adjust the path below as needed sys.path.insert(0, '/home/username/django_project') os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings' from django.core.wsgi import get_wsgi_application application = get_wsgi_application()

Replace 'django_project.settings' with your actual settings module path if different.

Step 5: Install Project Dependencies

  1. Go back to Setup Python App in cPanel.

  2. Click the pencil (edit) icon next to your app.

  3. Scroll down and click Enter to Virtual Environment.

  4. Run:

     
    pip install -r requirements.txt

Step 6: Database & Migrations

  1. Create a database from cPanel > MySQL® Databases.

  2. Update your settings.py with the correct DB name, user, and password.

  3. In the virtual environment terminal:

     
    python manage.py migrate

Step 7: Run Collectstatic (If Needed)

If you're using static files (CSS, JS, images):

python manage.py collectstatic

Make sure to set the correct STATIC_ROOT in your settings.py.

You're Live!

Visit your domain or the subdirectory you assigned. If everything is set correctly, your Django app should be up and running on Prabhu Host.

 Optional Tips

  • Set DEBUG = False and add your domain to ALLOWED_HOSTS before going live.

  • Use .env files or os.environ for sensitive credentials.

  • Add custom error pages (404.html, 500.html) for production use.


Was this answer helpful?
« Back