![How to host django website on cpanel](/media/blog_images/cpanel-hosting.png)
What kind of information will you get from this blog?
- 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 :
- Buy your domain (example: publicblogs.in ) and hosting
- Login in the cPanel
- Go to the Domains section and set the website file directory
- Software section and set up Python web application with same file directory
- Go to the terminal and run commands
- Go to the file manager section and upload website files in the file directory
- Change passenger_wsgi.py file
- Go on the Python web application and update or refresh it
- 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 , Bigrock, Hostinger, etc. Choose any company according to your requirements.
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.
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.
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.
Do you dream of turning your thoughts and words into income ? join us now and become blogger now.
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 :
- install Django ( pip install Django )
- start project ( django-admin startproject myproject )
- Go inside the project ( cd my project )
- 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.
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
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
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.
Is it necessary to modify the "passenger_wsgi.py" file
Yes, it may be necessary to modify the "passenger_wsgi.py" file to configure the Python application correctly.