Deploying a Django Application on Cpanel | Beginner's Guide
Tags: programming, cpanel, django
Published: 2023-12-13 14:21:54



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrtdqrisllg7djaix05o.jpg)

Deploying a Django Application on Cpanel | Beginner's Guide

Cpanel has become, in the vast world of hosting platforms, one of the widely used solutions by companies to deploy web application solutions. Notable providers include o2switch, Hostinger, LWS, and many others that you can find on the internet. However, it is often observed that Cpanel is particularly optimized for Content Management Systems (CMS) such as WordPress, Joomla, Drupal, and many others.

The task may appear challenging, especially for those who engage in programming from scratch. Despite the plethora of online assistance sites, I personally struggled for over six months to deploy a simple site that performed basic CRUD operations (Create, Read, Update, and Delete) on Cpanel with Django. I assure you, it can be a real frustration, especially when people expect results from you.

Today, I unveil the process for any beginner who does not want to use expensive web hosting solutions for their portfolio, blog, or small e-commerce site by adopting this solution.

What is Cpanel?
Cpanel is a common dashboard for managing web servers. It is highly popular among shared hosting providers. Without Cpanel, technical skills would be necessary for the configuration. However, not all hosting providers use Cpanel.

Configuration
Firstly, to initiate the deployment, you must have your project ready with basic configurations in the settings.py file.

You need to configure the settings for static files.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y754wnjfbbdq03xqdqbe.png)

urls.py file Configuration 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e9vo627qkzcw8d3s0ol6.PNG)


Pay close attention to the re_path; these are the two paths that will allow you to access the images stored in the database.

Here are the two important configurations you need to make. Ensure that you have created your .environ file to protect your secret keys and to avoid any potential attacks by hackers.

After this step, make sure you have your requirements.txt file.

Next step: Importation of your zip file.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q00ei4v64mwpz5lg8obv.PNG)

After this step, move on to your Cpanel dashboard.
• Create your application.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2rz6d8fzt2drk9scedgh.PNG)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kr0pzxnmrvem9dqmf71k.PNG)

• Install the dependencies in the requirements.txt file.

For security reasons, I won't be able to set up the virtual environment.

• Configure the settings.py file for production.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0dna1s2kc7tf659hl36.PNG)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q6cvnaynn7sjr40zo51w.PNG)

passenger_wsgi.py configuration 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46f7hhc6q1dauroh5uob.PNG)
You must install the "whitenoise" library to enable your CSS styles to function on the site.

After these steps, the last step is to restart the server or, at least, the application. Once these steps are completed,
Congratulations, we have successfully deployed our site on Cpanel.

You can check your site in the Google search bar, and you're all set.

In conclusion, deploying on cPanel provides a user-friendly and accessible approach to managing your web hosting server. With its intuitive graphical interface, you can efficiently carry out deployments, even without in-depth technical expertise. However, it is always essential to follow security best practices and consider the specific requirements of your project when deploying on cPanel. By leveraging this platform, you simplify the management process and provide an optimal experience for your end users.

Thank you for reading, and see you soon for a new article.