Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to install and set up Django in cPanel

This guide shows you how to run a Django website on your hosting account with the cPanel Python tool.

cPanel2 min read20 steps

What is Django?

Django is a toolkit for building websites with Python. Python is a popular programming language. A toolkit saves time because it has ready parts for logins, forms and databases.

cPanel has a tool named Setup Python App. It may not be on every plan. Ask Hostvento support if you cannot see it.

Part 1: Create the Python app

  1. Log in to cPanel.
  2. In the Software section, click Setup Python App.
  3. Click Create Application.
  4. Choose a Python version. Pick one that your Django version supports.
  5. In Application root, type a folder name, for example mydjango.
  6. In Application URL, choose your domain.
  7. Leave the startup file and entry point boxes empty for now.
  8. Click Create.

cPanel makes a virtual environment for you. This is a private box of Python add-ons for one project. It keeps projects from mixing. The page shows a command to enter it. Copy that command.

Part 2: Install Django

  1. Open Terminal in cPanel. Or connect by SSH.
  2. Paste the command you copied. It starts with source. It enters the virtual environment.
  3. Install Django.
    pip install django
    pip is Python's tool for adding packages.
  4. Start a project in your app folder.
    cd ~/mydjango
    django-admin startproject mysite .
    This makes the starter files. The dot at the end puts them right here.

Part 3: Connect Django to the web server

  1. Open the file passenger_wsgi.py in your app folder. cPanel made it. If it is missing, create it.
  2. Replace its contents with this.
    from mysite.wsgi import application
    This tells the server where your Django app starts.
  3. Open mysite/settings.py in File Manager.
  4. Find ALLOWED_HOSTS and add your domain.
    ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com']
    Django will answer only for these names.
  5. Add a static files folder.
    STATIC_ROOT = BASE_DIR / 'static'
  6. Back in the terminal, run these.
    python manage.py migrate
    python manage.py collectstatic
    The first sets up the database tables. The second gathers your CSS and images.
  7. Back in Setup Python App, click Restart.
  8. Open your domain. You should see Django's welcome page.

Set DEBUG = False before you go live. Debug mode shows secret details when errors happen.

Tip: Restart the app each time you change code. If you see errors, check the stderr.log file in the app folder.

Quick recap

  • Create the app with Setup Python App.
  • Install Django with pip inside the virtual environment.
  • Link it through passenger_wsgi.py and set ALLOWED_HOSTS.
  • Run migrate and collectstatic, then restart.