Deploy Django App in Hostinger with OpenliteSpeed

HermantoXYZ
3 min readAug 13, 2024

--

The OpenLiteSpeed Django One-Click app automatically installs performance web server OpenLiteSpeed, and Django. This image tends to be up to 2.5 times faster than Django on Nginx with Gunicorn! Developers can update files directly without using the built-in development server. OpenLiteSpeed features easy setup for SSL and RewriteRules.

Quick Start

Connect using terminal

ssh root@use_your_server_ip

An interactive script that runs will prompt you for your domain or subdomain:

Please input a valid domain:
Please verify it is correct. [y/N]

if your domain is already pointed to this server, you will have the option of automatically applying Let’s Encrypt SSL. Enter y and your email address to complete the process:

Do you wish to issue a Let's encrypt certificate for this domain? [y/N]
Please enter your E-mail:
Please verify it is correct: [y/N]

Once finished, you should see Certificate has been successfully installed...

Do you wish to force HTTPS rewrite rule for this domain? [y/N]

Visit the default script by entering http://Server_IP/ on your browser and you should see Hello, world!.

You can also enter http://Server_IP/admin/ to get the Django administration page

Start editing the Django project under /usr/local/lsws/Example/html/

Please access into virtual environment first

source /usr/local/lsws/Example/html/bin/activate

Update system software.

sudo apt update && sudo apt upgrade -y

Your system is installed and to use..

Set Up Demo Django Project:

Change owner:

chown -R nobody:nogroup /usr/local/lsws/Example/html/demo

Login to dashboard litespeed :7080/login.php

Set up a context via Web Admin > Virtual Hosts > Context > Add

And..

  • Type = App Server
  • URI = /
  • Location = /usr/local/lsws/Example/html/demo/
  • Binary Path = /usr/local/lsws/fcgi-bin/lswsgi
  • Application Type = WSGI
  • Startup File = demo/wsgi.py
  • Environment = PYTHONPATH=/usr/local/lsws/Example/html/lib/python3.8:/usr/local/lsws/Example/html/demo
  • Environment = LS_PYTHONBIN=/usr/local/lsws/Example/html/bin/python

How to Access the Installed Software

cat .litespeed_password

Visit https://use_your_droplet_ip:7080 to access WebAdmin in a browser.

By default, WebAdmin uses port 7080. To allow access to 7080 from your IP(e.g. 1.2.3.4):

ufw allow from 1.2.3.4 to any port 7080

You can also allow all IPs access to port 7080:

ufw allow 7080

ufw delete allow 7080

How do I Restart the Python Process?

killall lswsgi (KILL ALL)

--

--

No responses yet