Setup Django in hosting server

  1. Login to cpanel -> SOFTWARE -> Setup python App

2. Now you will see the below window and click on CREATE APPLICATION

3. Configure python version, Application root, Application URL, Application startup file, Passenger log file etc.

4. Now click on create button then you will see the below window.

5. Now go to browser and type the application url. In my case it is ” http://mis.nazimuddin.xyz

you will see the below words:

It works!

Python 3.3.7

6. Open Terminal from ADVANCE module. By default it is not available, in that case request your web hosting provider to enable it.

7. Copy the link selected above in the image. In my case it is:

 source /home/nazimudd/virtualenv/MISNRB/3.3/bin/activate && cd /home/nazimudd/MISNRB

8. Paste in terminal and press Enter Button to run the command

9. Then reun the command:

pip install django

10. WOW! Django is already installed

11. Now run the below command in Terminal

django-admin startproject project .

12. Now open passenger_wsgi.py file and remove all code and paste the below code

from project.wsgi import application

13. Now click on save button

14. Now open settings.py file under project directory and configure ALLOWED_HOSTS

15. Now paste the below code at the bottom line of the settings.py

import os
STATIC_URL = '/static/'
MEDIA_URL='/media/'
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'assets'), )
STATIC_ROOT='/home/nazimudd/public_html/static'
MEDIA_ROOT='/home/nazimudd/public_html/media'

Now run the below code in the Terminal

python manage.py collectstatic 

[Note: your python version must be more than 3.3 otherwise it will make error for above code]

17. RESTART the python APP from the below window

Now go to the browser and copy the app url. In my case it is http://mis.nazimuddin.xyz

Leave a Reply

Your email address will not be published. Required fields are marked *