Knowledge Base
MilesWeb / cPanel

Steps to Install and Configure Django from cPanel

Approx. read time : 4 min

A Python-based framework, Django enables you to create powerful websites in a quick and easy way. In this article, you will learn to install and configure Django using cPanel.

After you complete the procedure of installation and configuration of Django, your site will be able to:

  • Load a static homepage for the domain.
  • Load the Django administration interface.
  • Use a SQLite database.

Create A Python Application In cPanel

At first you will need to create a Python application within cPanel to host the Django project. To do this, follow these steps:

1. Log in to cPanel.

2. Go to the SOFTWARE section of the cPanel home screen and click on Setup Python App.

3. Under Setup new application, select 3.6 in the Python version list box.

4. Type myapp in the App Directory text box.

5. Choose the domain you want to use in the App Domain/URI list box and then leave the URI text box empty.

6. Click on Setup. With this, cPanel creates the application and sets up the Python environment.

7. Under Existing applications, copy the command from the Command for entering the virtual environment. This information will be needed in the following procedure.

Configure The Django Project

After creating the Python application in cPanel, you will need to do the following tasks at the command line:

  • Install Django.
  • Create and configure the Django project.
  • Configure Passenger to work with the Django project.

For this, follow the below steps:

1. Log in to your account using SSH.

2. Use the command you noted in the above step to activate the virtual environment. For example:
source /home/username/virtualenv/myapp/3.6/bin/activate

Note: Since the command prompt starts with (myapp:3.6), it indicates that you are working in the myapp virtual environment with Python 3.6. The following commands in this article are mentioned assuming that you are working in the Python virtual environment. In case you log out of your SSH session (or deactivate the virtual environment by using the deactivate command), ensure you reactivate the virtual environment prior to following any of the steps below.

3. Type the below command to install Django:

You can verify the version of Django installed, with the following command:

4. Type the below command for creating a Django project:

5. In order to create directories for the static project files, use the below commands:

6. Open the ~/myapp/myapp/ file by using the text editor, and then make the following changes:

  • Find the ALLOWED_HOSTS line and then modify it as below. Replace with your own domain name:

  • Find the TEMPLATES block, and then modify it as below:

  • Locate the STATIC_URL line, and then add the below lines beneath it:

7. Open the ~/myapp/myapp/ file using the text editor. Delete the existing text and copy the below text into the file:

8. Open the ~/myapp/ file and do the following changes. Replace username with your own account username:

9. For creating a basic index.html file in the ~/myapp/templates/static_pages directory. The file can be as simple as a text file that says Hello world.

10. Type the following command:

11. Create and set up the superuser account:

  • For this, type the below command:

  • Type the administrator username at the Username prompt and then press Enter.
  • Type the administrator e-mail address at the Email address prompt and then press Enter.
  • Type the administrator password at the Password prompt and then press Enter.

12. To collect the static files, type the below commands:

In case you are asked for overwriting existing files, type yes and then press Enter.

13. Restart the Python application in cPanel:

  • Log in to cPanel.
  • Click Setup Python App in the SOFTWARE section of the cPanel home screen.
  • Locate the correct application under the Existing applications and then click Restart.

14. Test the Django site:

  • Go to, where represents your domain name. The index.html file should load.
  • Go to, where represents your domain name. The Django administration login page should be displayed. Use the superuser credentials that you created earlier to log in.

If there is a problem for the website to appear in your browser, run the file manually. For this, type the below command:

When you run this file, you should get any text output to the console. In case there are any errors, check the syntax in the configuration files.

That’s all! Now, you can easily install and configure Django from your cPanel.

Pallavi Godse
Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.