[Tutorial] How to run Python Django on cPanel
Articles,  Blog

[Tutorial] How to run Python Django on cPanel

Hello, This is Jammie from iFastnet. In this tutorial we’re going to set up a django website in cpanel First enter Setup Python App in your cpanel hosting Choose the python version you need here and enter a name for the root directory of your application cPanel now creates a virtualenv for us To enter the virtualenv you need to copy this command and paste it in the shell of your account and we’re in, we can now use pip to install django Django is now installed Now navigate to the root folder of your application and create a django project in this folder We need to set the webserver to serve our django project. Open the passenger_wsgi.py fil and import the the application from your django wsgi file Now open the settings file of django Add your domain name to allowed_hosts in the file Add the media URL and set staticfiles_dirs variable I add assets folder to this variable so I can upload my static files in the assets folder here Set STATIC_ROOT and MEDIA_ROOT variables to the root folder of your domain now I create the assets and media folders that I set and run ./manage.py collectstatic so that django collects static files to the static_root folder Finally need to restart the web server. Remember this is a production environment and you need to restart the web server whenever you update your code Let’s refresh the page and we’re all set ! Happy coding !


  • Daian Gan

    It is not an standard in cPanel hostings. You will need a WHM account with root access to install CloudLinux and set it up by yourself or just buy a cPanel hosting with it already included.

    Follow this thread for more information:

    The "Setup Python App" option is included as part of the Python Selector feature in CloudLinux:
    It's not offered with cPanel & WHM unless CloudLinux is installed.

  • Mahmud Kabir

    Thanks a lot! I struggled for almost a week and finally found the "It worked!" page. Thanks to 'Rahi' who recommended this video.
    * I had to struggle a lot because I was trying to host it on a subdomain. I think that is not possible now. If anyone knows how to configure that please consider to share. (I had to host it on the root) *

  • Dibu Escobedo

    Hello, I need some help, when I try to edit the setting.py file from cpanel, I can't access for permissons, how can I fix it? THX DUDE!

  • Iqbal Syed

    I don't see Python Setup in my Cpanel. It shows PHP PEAR Packages, Perl Modules, Site Software, Optimize Website, Softaculous Apps Installer and Select PHP Version only in Sofware group of Cpanel. What should I do if I have a make a Python or Node.Js based application for my client who is using this hosting service from Cyber Net? The website hosting is taken from Cyber Net in Pakistan.

  • Diganta Protik

    We're sorry, but something went wrong.
    The issue has been logged for investigation. Please try again later.

    Web application could not be started by the Phusion Passenger application server.

  • Wei158

    I tried this but there nothing happing, but I get an error page instead, can someone help I been trying for the whole week?

  • Nabil Ezz

    This video is not true i was buy host from this company and I'm do everything like video but is not work … don't buy host from this company if you need host support python and django you need to go to digitalocean this company is sooo good

  • Md. Firoz Mahmud

    I do that everything same like the video but when run " ./manage.py collectstatic " then showing many error, not understand where is the problem. Need help!
    and present situation : www.mytarzan.com
    Error : https://ibb.co/kDCvy9L

  • Abhishek Kumar

    Good Evening everybody,
    I am getting such msg. Please suggest why I got this error.

    (project:3.7)[[email protected] project]$ ./manage.py collectstatic

    Traceback (most recent call last):

    File "./manage.py", line 21, in <module>


    File "./manage.py", line 17, in main


    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line


    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute


    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/__init__.py", line 24, in setup


    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate


    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models

    self.models_module = import_module(models_module_name)

    File "/home/austere/virtualenv/project/3.7/lib64/python3.7/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

    File "<frozen importlib._bootstrap>", line 1006, in _gcd_import

    File "<frozen importlib._bootstrap>", line 983, in _find_and_load

    File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked

    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked

    File "<frozen importlib._bootstrap_external>", line 728, in exec_module

    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/contrib/auth/models.py", line 2, in <module>

    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 47, in <module>

    class AbstractBaseUser(models.Model):

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/models/base.py", line 117, in _new_

    new_class.add_to_class('_meta', Options(meta, app_label))

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/models/base.py", line 321, in add_to_class

    value.contribute_to_class(cls, name)

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/models/options.py", line 204, in contribute_to_class

    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/_init__.py", line 28, in __getattr_

    return getattr(connections[DEFAULT_DB_ALIAS], item)

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/utils.py", line 201, in _getitem_

    backend = load_backend(db['ENGINE'])

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/utils.py", line 110, in load_backend

    return import_module('%s.base' % backend_name)

    File "/home/austere/virtualenv/project/3.7/lib64/python3.7/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 66, in <module>


    File "/home/austere/virtualenv/project/3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 63, in check_sqlite_version

    raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found %s).' % Database.sqlite_version)

    django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).

    Thank you

Leave a Reply

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