---
title: How to Setup or Deploy Django on Cyberpanel
description: "This guide will take you step by step on how to successfully host your Django Application on Cyberpanel running Almalinux OS or Ubuntu OS #### **Requirements**: **Accessibility** : **`Root Access to the server.`** **Operating** **System**(**OS**): `Almalinux 8` or`Ubuntu 22` **Application**:…"
url: "https://truehost.com/support/knowledge-base/how-to-setup-or-deploy-django-on-cyberpanel/"
updated: "2025-08-20"
category: Cyberpanel
---

# How to Setup or Deploy Django on Cyberpanel

This guide will take you step by step on how to successfully host your Django Application on Cyberpanel running Almalinux OS or Ubuntu OS

#### **Requirements**:

**Accessibility** : **`Root Access to the server.`**

**Operating** **System**(**OS**): `Almalinux 8` or`Ubuntu 22`

**Application**: **`Django`**

#### **Step 1: Installing Python**

If you're okay with **default** version of Python installation on Almalinux or Ubuntu, you can skip to step **Step 3**;

By **default**, Almalinux 8 comes with python version**3.6**. while Ubuntu 22 comes with python version 3.10 However, this version may not be suitable to run our application. In this case, we need to easily install another version of Python say **`3.7, 3.8, 3.9, 3.10, 3.11, 3.12,`** as needed.

NOTE: We recommend custom installation to avoid using system python to avoid interferance with core systems.

In this guide, I'll show you how to Install our own version.

We shall install python **`3.8`**in our case. (Feel free to install your preferred version, all steps are the same)

We shall be using `pyenv` - > A package to install and manage multiple python versions. See more

[https://github.com/pyenv/pyenv](https://github.com/pyenv/pyenv)

##### **Installing Required packages .**

#### **Almalinux**

**`yum -y install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel mysql-devel pkgconfig libpq-devel`**

![](https://truehost.com/support/wp-content/uploads/2024/12/image-105-1024x444.png)

##### **Install Development packages.**

`yum -y groupinstall "Development Tools"`

![](https://truehost.com/support/wp-content/uploads/2024/12/image-106-1024x350.png)

#### Ubuntu

`apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl python3-dev libmysqlclient-dev pkg-config libpq-dev`

#### **Step 2: Download and Install pyenv**

##### **Download and Install pyenv**

`curl https://pyenv.run | bash`

![](https://truehost.com/support/wp-content/uploads/2024/12/image-107.png)

##### **Enable pyenv**

`echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc`

`echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc`

**`echo 'eval "$(pyenv init -)"' >> ~/.bashrc`**

![](https://truehost.com/support/wp-content/uploads/2024/12/image-108-1024x188.png)

Confirm pyenv is working;.

**`pyenv`**

You should see output similar to one below.

![](https://truehost.com/support/wp-content/uploads/2024/11/image-358-1024x472.png)

Installing Python 3.8 using pyenv

First type the command below to see available versions that can be installed using pyenv.

`pyenv install --list`

You should see output similar to one below. The output is very long , so just scroll until you find the version you want.

![](https://truehost.com/support/wp-content/uploads/2024/11/image-359-1024x383.png)

The below image shows our python 3 versions. You can choose any

![](https://truehost.com/support/wp-content/uploads/2024/11/image-360-1024x535.png)

To install version 3.8.20, type the command below. Since I had installed, I will not re-install.

`pyenv install 3.8.20`

![](https://truehost.com/support/wp-content/uploads/2024/12/image-109-1024x224.png)

Now you can make python 3.8.20 available globally by typing.

**`pyenv global 3.8.20`** (Replace with your installed version)

![](https://truehost.com/support/wp-content/uploads/2024/12/image-110-1024x215.png)

Now all is done as far as python installation is concerned.

#### **Step 3: Installing lswgi**

Download from Litespeed. At time of writing, lsapi-2.1 is the latest version.

To check see link below.

[https://www.litespeedtech.com/open-source/litespeed-sapi/download](https://www.litespeedtech.com/open-source/litespeed-sapi/download)

`curl -O https://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-2.1.tgz`

Extract the archive

`tar xf wsgi-lsapi-2.1.tgz`Navigate to the extracted directory

`cd wsgi-lsapi-2.1/`

Build wsgi with the new python version.

`python3 ./configure.pymake`

Copy the package to the fcgi-bin directory.

`cp lswsgi /usr/local/lsws/fcgi-bin/`

Confirm it is there `cd /usr/local/lsws/fcgi-bin/`

`ls`

![](https://truehost.com/support/wp-content/uploads/2024/12/image-111-1024x214.png)

#### **Step 4: Create a website on Cyberpanel.**

In this guide, I'll be using a sub-domain

[https://superdjango.lintsawa.com](https://superdjango.lintsawa.com)

![](https://truehost.com/support/wp-content/uploads/2024/12/image-112-1024x629.png)

Website created and now loads default cyberpanel page.

![](https://truehost.com/support/wp-content/uploads/2024/12/image-113-1024x448.png)

Upload your website files to the public_html folder and extract.

![](https://truehost.com/support/wp-content/uploads/2024/12/image-115-1024x566.png)

Navigate via SSH to **`cd /home/yourdomain.com/`**

Where necessary, replace with your domain name.

Create and activate virtual env

**`python3 -m venv /home/superdjango.lintsawa.com/myenv/`**

Activate.

`source /home/superdjango.lintsawa.com/myenv/bin/activate`

![](https://truehost.com/support/wp-content/uploads/2024/12/image-114-1024x279.png)

Navigate to your projects directory where you have your requirements.txt file

![](https://truehost.com/support/wp-content/uploads/2024/12/image-116-1024x192.png)

Install your project dependencies.

![](https://truehost.com/support/wp-content/uploads/2024/12/image-117-1024x299.png)

Migrate your database

![](https://truehost.com/support/wp-content/uploads/2024/12/image-118-1024x551.png)

Create your superuser.

![](https://truehost.com/support/wp-content/uploads/2024/12/image-119-1024x301.png)

Collect the static files

**`python manage.py collectstatic`**

![](https://truehost.com/support/wp-content/uploads/2024/12/image-120-1024x380.png)

Now for the app to load,

Go back to Cyberpanel dashboard > Websites > List Website > Manage > Configurations >vHost and Add the context below to vHost section of your domain.

Do NOT delete the existing details. Scroll to the bottom and add the context

Add Context.

Replace where necessary

Adjust your Location, startupFile and env
=================

```
context / {
    type            appserver
    location        /home/superdjango.lintsawa.com/public_html/portfolio-website-main
    binPath         /usr/local/lsws/fcgi-bin/lswsgi
    appType         wsgi
    startupFile     Portfolio/wsgi.py
    envType         1
    env             LS_PYTHONBIN=/home/superdjango.lintsawa.com/myenv/bin/python3
}
```

Screenshot.

![](https://truehost.com/support/wp-content/uploads/2025/01/image-32.png)

![](https://truehost.com/support/wp-content/uploads/2024/12/image-121-1024x638.png)

Restart openlitespeed.

**`/usr/local/lsws/bin/lswsctrl restart`**

![](https://truehost.com/support/wp-content/uploads/2024/12/image-122-1024x103.png)

Reload your website.

You should your site working well as expected.

![](https://truehost.com/support/wp-content/uploads/2024/12/image-123-1024x510.png)

Confirm you can also access the admin section.

![](https://truehost.com/support/wp-content/uploads/2024/12/image-125.png)

Congrats. You have successfully deployed your django website to Cyberpanel with Openlitespeed.

In case of Errors use command below to view the error messages for troubleshooting.
==========

**`tail -f /usr/local/lsws/logs/stderr.log`**

Example an Error as below.

error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

![](https://truehost.com/support/wp-content/uploads/2025/05/image-1024x105.png)

You can fix by running command below to install additional missing libraries.

***`sudo dnf install python38 python38-devel`***

Adjust the command to suit your python version needs.

![](https://truehost.com/support/wp-content/uploads/2025/05/image-1-1024x251.png)

Restart Openlitespeed.

Happy Hosting!!!
