Cantech Knowledge Base

Your Go-To Hosting Resource

Install and Configure Django from cPanel

Introduction

Django is a robust Python-based framework that enables you to develop robust websites in a fast and effective manner. Django projects are easy to install and set up using your cPanel account. This process will allow your site to function correctly, load a static homepage, show the Django administration interface, and work with a simple SQLite database.

What is Django?

Django is a high-level Python web framework that promotes speedy development and a pragmatic design. It has also been referred to as a batteries-included framework since it is pre-packaged with numerous features, including an ORM, an administrative panel, and a templating engine. You put Django into a Python environment, and it takes care of your web application logic.

Installation and Configuration of Django

The installation of Django on cPanel consists of two major sections. The first step is to develop the Python application in cPanel. Second, you set up the project files via SSH commands.

First, you have to set up a virtual environment for your Python application.

  • You are required to log in to your cPanel account dashboard.
  • Go to the SOFTWARE section of the home screen and click on the option of Setup Python App.
  • Under the heading of Setup new application, choose the preferred Python version. Select Python version 3.6 in the version box.
  • Enter the name of your application folder in the App Directory text box. We will use “myapp” here.
  • Choose the domain to be used in the App Domain/URI list box. Leave the URI text box empty.
  • Complete the configuration by selecting the Setup button. cPanel will create the application and prepare the Python environment.
  • Search in the Existing Applications section. Enter the command that is displayed to get into the virtual environment. You will need this command soon.

Configure the Django Project through SSH.

Once the application has been set up, you will need to install Django and configure the files. This requires using an SSH command-line interface.

  • You must log in to your account using an SSH client.
  • Turn on the virtual environment. Enter the command you have copied in the previous step, e.g.:
    source /home/username/virtualenv/myapp/3.6/bin/activate

The command prompt will change to indicate that you are in the virtual environment.

  • Install Django. Type the command cd ~ to move to the home directory and then pip install django==2.1.8 to install. Check the installation using django-admin –version.
  • Create the project: Type the command django-admin startproject myapp ~/myapp to create the basic project structure.
  • The following commands are used to create the necessary folders for static and template files:
  • mkdir -p ~/myapp/templates/static_pages
    mkdir ~/myapp/static_files
    mkdir ~/myapp/static_media 
    

     

  • Modify settings.py file
  1. Use a text editor to open the ~/myapp/myapp/settings.py file.
  2. Change the following:

ALLOWED_HOSTS: Find the line and change it to include your domain, e.g., ALLOWED_HOSTS = [‘example.com’].

TEMPLATES: Locate the TEMPLATES block. Modify the DIRS line to os.path.join(BASE_DIR,’templates’).

After the STATIC_URL line, add the following:

STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "static_media") 
  • Modify urls.py

Open the ~/myapp/myapp/urls.py file and delete the current contents and add the code to serve the static files and the index page. This code imports necessary components and defines the basic URL patterns.

  • Modify passenger_wsgi.py

Open ~/myapp/passenger_wsgi.py. In line SCRIPT_NAME, you need to replace username with your real account username. This file configures the web server on how to work with your Django application.

  • Create an index file

Write an index.html file in the directory ~/myapp/templates/static_pages, in the directory of your app. Add a small piece of text, such as the Hello World in this file.

  • Migrate the database

Type the command python ~/myapp/manage.py migrate to apply database migrations.

  • Create superuser

Run python ~/myapp/manage.py createsuperuser to set up an administrator account. Follow the prompts to enter a username, email, and password.

  • Collect static files

Type the command python ~/myapp/manage.py collectstatic. Respond to the question of whether to overwrite existing files by saying yes.

  • Restart the Python application.

Log in to cPanel again, click on Setup Python App, and then under Existing Applications, find your application, and then click on the Restart button.

  • Test the site

Open a web browser and navigate to the address of the website, such as: http://www.example.com, and see the index.html page load. Then go to the Django administration login page by visiting http://www.example.com/admin. Log in using your superuser account credentials.

Hosting Features of Cantech for You.

Cantech supports modern development platforms as Django.

Python Environment Support: Our hosting offers the required tools to create Python virtual environments with ease.

SSH Access: We provide SSH access that is necessary to complete command-line operations like installing Django and maintenance of the project.

Consistent Uptime: Our servers have been optimized to support Python and Django applications.

Conclusion

It is possible to install and configure a powerful Django project with the help of cPanel. It is a simple case of developing a Python application within cPanel and executing configuration commands using SSH, providing you with a strong base on which to develop your site.

FAQs About Django on cPanel

What is a Python virtual environment?

A Python virtual environment is a self-contained directory that holds a particular installation of Python and contains the dependencies of a project that is separate from other projects.

Why do I need to use SSH to install Django?

The SSH access is required since you need to use the pip install command that installs the Django package directly to that isolated Python virtual environment.

What is the role of the passenger_wsgi.py file?

The passengerwsgi.py file serves as a starting point to the web server, and it informs the web server of the correct way to communicate with and run your Django application.

Can I use a different database instead of SQLite?

Yes, you can. Change the database configuration in settings.py and make sure that the necessary database driver is in your virtual environment.

Why did I need to collect static files?

The collectstatic command collects all static files from your applications and copies them to a location defined by the STATIC_ROOT, ensuring that the web server serves them effectively.

January 19, 2026