There was a problem loading the comments.

Installation of Python Django in cPanel

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
  • 16 July 2020 11:12 PM

1. Log in to the cPanel control panel

2. In the Software section, select “Setup Python App

78ba703c78c628342919d6e2d8379b35bb524e7c?t=a2503ae1eb547330ed09d3b0abdc9e4d
3. Select Create Application to create a Python application

4e9d9cf70b0d91660082be6e8f0e3a393311ce0e?t=df02527596b6871d1897159571d94518
4. Select the desired Python version from the drop-down list. We have 2.7, 3.3, 3.4, 3.5, 3.6 Python versions on hosting.

5. Select the Application root, Application URL, Passenger log file.

528b9d78811ae9511f1c49caf765a1c1a45cc88d?t=99e99a045796c0cc531ac4fa7322b4ea
6. Click the “CREATE” button, wait until the installation is complete.

7. After installation, confirm whether the Python application is installed successfully by accessing the URL.

dc7b36b32ab8a784ead2edbc716c437a18967ab0?t=403d248a375622531d7a72cce1b6698c
8. Copy the command and run it in a terminal to enter a virtual environment.

cabac5702cfb8b3e1298ada4ecf8b947d47103d6?t=2f62a7b77de9e1fc60b300c503e063c0 86c2db861443706b54dfb4d75afb98e50b26190c?t=3740b0adf68178b7761b545ad5397834
9. Now install Django using the command

pip install django

d763299bbfe9eeb0f33e5c5271f59930ad99a392?t=9765029ffa166063a522da8401b41b57
10. Start the project

django-admin startproject project .

11. Open File Manager and edit passenger_wsgi.py from your newweb folder/project installation folder

12. Remove all the content from passenger_wsgi.py file and update following and save the file

from project.wsgi import application

13.  From project folder edit settings.py

14. Find and update the allowed host values in file with your domain name or application URL.

ALLOWED_HOSTS = ['mydomain.in','www.mydomain.in']

15. Add the following code at bottom of settings.py file for media and application path.  Remove cpuser in the below path and enter your cPanel username.

MEDIA_URL='/media/'
STATICFILES_DIRS=[BASE_DIR +"/assets",]
STATIC_ROOT='/home/cpuser/public_html/static'
MEDIA_ROOT='/home/cpuser/public_html/media'
16. Create assets folder in application root (For e.g. newweb)
17. Create a media folder under public_html
18. execute the following command from a terminal

python manage.py collectstatic
16e01b45e1b422b938ac2251c4c68aaf80b8877b?t=1cd36ffd8319aa190568933ffa633a0d
19. Restart the Python application from setup python app in cPanel.

4f8a175a0e619be8221251de08c8dc3176169f7b?t=55df32f75d0e6690d39b534dda64b1b8
The Django application is successfully installed.

Share via
Did you find this article useful?  

Related Articles


Self-Hosted Help Desk Software by SupportPal
© Glosting