How to host django website on cpanel

Dec. 6, 2023 by shrikant patel Posted in programming Category 1 Comments 235 Views

How to host django website on cpanel

What kind of information will you get from this blog?

  1. Learn about Cpanel and how to host a Django website on it.

    If you want to be a website or full-stack developer. So you have to learn about how to create a website, thereby creating new websites to provide information and services to people. For this, it is important to keep your website online 24 x 7, which is why you need to host and store your website on a server. In this blog, we will learn in a systematic manner how you can host or live your website on Cpanel.

A systematic way to host your website :

  1. Buy your domain (example: publicblogs.in ) and hosting 
  2. Login in the cPanel
  3. Go to the Domains section and set the website file directory
  4. Software section and set up Python web application with same file directory
  5. Go to the terminal and run commands
  6. Go to the file manager section and upload website files in the file directory
  7. Change passenger_wsgi.py file
  8. Go on the Python web application and update or refresh it
  9. Now your website is live

 

Buy Domain and Hosting :

First of all, select and purchase your domain, either based on personal choice or according to your business and similarly, buy hosting services from any web hosting company. some domain and web hosting services providing company names are Godaddy , BigrockHostinger, etc. Choose any company according to your requirements.

godaddy website

 

 

Login in the cPanel : 

Once you purchase hosting and domain, you will receive the cPanel username and password, or you can directly access the cPanel from the hosting provider. Once obtained, proceed to log in to the cPanel.

 

cpanel login page

 

Select domain and website file directory location :

After logging in, navigate to the "Domains" section in the cPanel, than go to the "Domains" option, select your domain, and create the website files document root location.

Login > Domains section > Domains option 

than choose the option to select an existing domain or create a new domain. If you are creating a new domain, than input the same domain name you purchased along with the hosting for your website.

create document root location

 

Domains option > Create new domain / select domain > set documnet root location

Uncheck the "Share document root" option, then provide a folder name according to your choice. Afterward, submit, and your domain will be successfully connected to your hosting account.

 

Setup Python web application :

To set up a Django website, in navigate to the "Software" section and proceed to the "Setup Python App" option.

Software > setup python app > create new web application

To create a web application, first, select the Python version according to your requirements. Then, set the document root location to match the one you chose for the domain. Afterthat, choose the domain for which you are creating the website and submit the form. Once completed, you will see the location of the web application; now, copy that location.

setup web application

Do you dream of turning your thoughts and words into income ? join us now and become blogger now.
PUBLICBLOGS.IN


Go to the terminal and run commands:

After copying the web application location, open the terminal, paste the link, and press the enter button. You are now inside the web application. Execute the Django commands to create the Django project and initiate an app for your website.

Advanced section > terminal option > paste the web application location

Django commands that you have to run after entering the web application : 

  1.  install Django ( pip install Django )
  2. start project ( django-admin startproject myproject )
  3. Go inside the project ( cd my project )
  4. Create an app ( python manage.py startapp myapp )

If you want to learn more about creating a Django website, refer to my previous blog post titled "Django Tutorial: How to Create Your First Django Project." This blog provides comprehensive information on starting a Django application, offering valuable insights for starting your developer journey.

cpanel terminal

Upload website files in the website document root directory :

 

Navigate to the "Files" section and proceed to the "File Manager" option. Access the website's document root location and upload your Django web application code files.

Files section > file manager option > website document root location

file manager of cpanel

Change passenger_wsgi.py file :

 

Enter in to the website's document root files location and locate the "passenger_wsgi.py" file. Modify the code in the file as follows: from myProject_name.wsgi import application  where in place of myProject_name you have to write you django project name.

find passenger_wsgi.py > modify code according the project name

 

from myProject_name.wsgi import application

 

passenger_wsgi.py file

 

After modifying the code, return to the Python web application, and refresh the web application. You will now see that your website is live and accessible.

 

Conclusion

From this blog, you've learned how to host your Django website on cPanel. I hope you found valuable information about website hosting. Thank you for reading! If you have any further questions than comment it.

Some related questions on website hosting :

1. What is the SSL certificate?

Answer: SSL, which stands for "Secure Sockets Layer", is a standard security technology for creating an encrypted link between a web server and browser. SSL certificates are digital certificates that authenticate the identity of a website and encrypt information sent to the server using SSL technology.

2. How to manage Django packages on cPanel hosting environments?

Answer: The best way to manage Django applications on cPanel consists of maintaining web application programs, code, and frameworks up to date, configuring secure report permissions, implementing ordinary backups, and tracking server logs for any safety or overall performance issues.

programming website
If you went to earn online by just sharing your thoughts then join us now with Google and become blogger now.
PUBLICBLOGS.IN
Related Story
1 Comments
  1. profile image
    shweta 7 months

    Is it necessary to modify the "passenger_wsgi.py" file

    • profile image

      Yes, it may be necessary to modify the "passenger_wsgi.py" file to configure the Python application correctly.

Leave a Comment