How_to_deploy_DJANGO_app_on_CyberPanel.jpg

How to deploy DJANGO app on CyberPanel

Django is a very popular free and open-source web application framework that is written in Python Language. A framework is made up of collections of modules that make development smoother and easier. Using Django frameworks it will save a lot of time and reduce the risk of bugs. You don't have to write everything from the beginning, so there's a very low probability of introducing errors or bugs.

These are the following step to install Django on CyberPanel -

1. Upgrade OpenLiteSpeed -

 For CentOS-

yum update
yum upgrade openlitespeed

If you are using Ubuntu then,

apt-get update
apt-get upgrade openlitespeed

2. Install python -

 For CentOS-

yum install python36-devel
yum install python36-pip

If you are using Ubuntu then,

apt install build-essential
apt-get install python3-dev

3. Download the Litespeed web server gateway interface -

Run these command-

curl -O http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.7.tgz
tar xf wsgi-lsapi-1.7.tgz
cd wsgi-lsapi-1.7
python3 ./configure.py
make
cp lswsgi /usr/local/lsws/fcgi-bin/

4. Install and Start Virtual Environment for Django Application -

virtualenv --system-site-packages /home/tag2seo.com/public_html
source /home/tag2seo.com/public_html/bin/activate

5. Install Django -

pip install django

or

pip3 install django

6. Setup DJANGO Project -

Note- Here we are creating a new Django project from the beginning and our project name is myproject. 

If you have already Django project then don't create a new project just upload your project in the root directory.

you can upload your project through a file manager or FileZilla(By using an FTP account)

cd /home/tag2seo.com/public_html
django-admin startproject myproject

7. Changes in setting File - 

you can find the setting file at /home/tag2seo.com/public_html/myproject/myproject/settings.py

ALLOWED_HOSTS = ['*']

 For static files please add these code below the setting.py file

STATIC_URL = '/static/'

STATIC_ROOT = '/home/tag2seo.com/public_html/static'

Note- Don't forget to save setting.py file

Run the below command

cd /home/tag2seo.com/public_html/myproject
python manage.py collectstatic
python manage.py migrate
python manage.py createsuperuser

8. Update the vhosts Configuration

Add the bunch of the code in vhost Conf

context / {

  type                    appserver

  location                /home/tag2seo.com/public_html/myproject

  binPath                 /usr/local/lsws/fcgi-bin/lswsgi

  appType                 wsgi

  startupFile             myproject/wsgi.py

  envType                 1

  env                     LS_PYTHONBIN=/home/tag2seo.com/public_html/bin/pyhton

  env                     PYTHONHOME=/home/tag2seo.com/public_html/

}

 

Replace tag2seo.com with your domain name and myproject with your project name

After saving the vhost Conf you should now be able to visit your website and see the affected changes.

Latest Posts

How_to_deploy_DJANGO_app_on_CyberPanel.jpg
How to deploy DJANGO app on CyberPanel 16 Dec, 2021

Categories