How to setup DJANGO application on CyberPanel/OpenLiteSpeed

DJANGO is a web application framework built with Python. DJANGO seen a tremendous growth recently, and a lot of developers are moving towards this framework. DJANGO official slogan says “the web framework for perfectionists with deadlines”. CyberPanel is also built on top of DJANGO framework, apart from that Instagram also uses DJANGO framework.

OpenLiteSpeed recently added support to run DJANGO applications at VHOST level. Now there is no need to reverse proxy your DJANGO application to gunicorn server. This also leads to increased performance.

In this tutorial we will see how we can setup a DJANGO application. (OpenLiteSpeed version 1.4.42+ is required)

Step 1: Install CyberPanel and Create Website

Before moving forward you need to install CyberPanel and Create Website. If CyberPanel is already installed, make sure to upgrade OpenLiteSpeed.

Upgrade OpenLiteSpeed on CentOS

yum update
yum upgrade openlitespeed

Upgrade OpenLiteSpeed on Ubuntu

apt-get update
apt-get upgrade openlitespeed

Install python 3.6 on CentOS

yum install python36-devel
yum install python36-pip

Install python 3.6 on Ubuntu

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

Step 2: Install LiteSpeed Implementation of WSGI

curl -O
tar xf wsgi-lsapi-1.7.tgz
cd wsgi-lsapi-1.7
python3 ./
cp lswsgi /usr/local/lsws/fcgi-bin/

Step 3: Setup virtualevn for DJANGO Application

Note: In this tutorials we are going to use as example domain and cyberpanel as project name.

We will setup virtualevn in the document root of the application:

virtualenv --system-site-packages /home/
source /home/
pip3 install django

Step 4: Setup or Upload DJANGO Application

If you already have DJANGO application you can upload it to document root, we will create a brand new DJANGO project.

cd /home/
django-admin startproject cyberpanel

Open your project settings and make sure allowed hosts looks like

ALLOWED_HOSTS = ['*'] for this project will be located at /home/

To set path for static files please add following at the end of

STATIC_URL = '/static/'
STATIC_ROOT = '/home/'

And create folder to start to collect your static files using

cd /home/
python collectstatic

Create admin super user

python migrate
python createsuperuser

Note: Always replace with your domain name.

Since you are modifying/creating files via command line, you can go to File manager and click Fix Permissions so that correct permissions settings are in place.

Step 5: Setup DJANGO Application Context

Go to website launcher at https://:8090/websites/ so that you can edit vhost Conf (Replace with your domain).

Scroll down and click vhost Conf and paste following at the end of the box:

context / {
  type                    appserver
  location                /home/
  binPath                 /usr/local/lsws/fcgi-bin/lswsgi
  appType                 wsgi
  startupFile             cyberpanel/
  envType                 1
  env                     LS_PYTHONBIN=/home/
  env                     PYTHONHOME=/home/

env LS_PYTHONBIN=/home/ is the location of python inside your virtualenv. Make sure you replace domain and project name in above settings accordingly.

Once done click Save and you can visit your DJANGO application at, in this case, its It should look like:

You can also check admin panel at


1 Like

It seems like this does not work on latest version of CyberPanel.



it works perfectly fine

by seeing your posted error post , for problem check file permissions or ssl issue

I have tried everything i can.
I have also tried running it internally from the website list.
It gives the same issue.
Goes to 403 for some reason.

Internal SSL is let’s encrypt and external SSL is CloudFlare.


i have 10 Django sites hosted on cyber-panel its perfectly fine.
can you post detailed info about server?

Contabo Centos 7

6 vCPU Cores


400 GB SSD

2 Snapshots

32 TB TrafficUnlimited Incoming

All packages up to date
sudo yum check-update
sudo yum update

Error messages from OpenLieSpeed fail to load “Error redirect too many times”.
Other than error messages and django, everything else works.

Hi all,

I’ve read this same tutorial on 3 websites and a youtube video and all have “pyhton” written with the same typo. Is this really a typo or is there some other hidden reason for it?

I do think it’s a typo, but i still can’t get the tutorial to work.
Standard blank CyberPanel HTML shows up, but nothing else.
I have tried both with the typo and without.

That strange as I’ve got it to work quite easily on mine. And it works whether the typo is there or not.

Are you inserting the context part at the bottom of your vhosts file? I first made the mistake of replacing it entirely.

And then of course there’s the 5 parts of that config that you need to change.

can you please tell me how can I upload my existing django project in document root.

This tutorial is not working with Django 3, can you update it?

An internal server error has occured. Internal Server Error 500
can you help me please

Restart your server and post the errors you are getting here https://<IP Address>:8090/serverstatus/cyberCPMainLogFile

1 Like