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/settings.py file by using the text editor, and then make the following changes:

  • Find the ALLOWED_HOSTS line and then modify it as below. Replace example.com 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/urls.py file using the text editor. Delete the existing text and copy the below text into the file:

8. Open the ~/myapp/passenger_wsgi.py 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 http://www.example.com, where example.com represents your domain name. The index.html file should load.
  • Go to http://www.example.com/admin, where example.com 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 passenger_wsgi.py 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.

Avatar
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.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent 4.8 out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna