Install Django on CyberPanel and Openlitespeed with WSGI



Install Django on CyberPanel and Openlitespeed with WSGI

  • Step 1 : Install LiteSpeed Implementation of WSGI
  • Step 2 : Create site:
  • Step 3: Create Virtual Environment
  • Step 4: Install Django
  • Step 5: Create Django Project
  • Step 6: Modify Django settings
  • Step 7: Create context in OpenLiteSpeed
  • Step 8: Verify Django Installation

The setup is with virtual environment.

Step 1 : Install LiteSpeed Implementation of WSGI

Install Python 3 libraries required for compilation

yum update
yum upgrade openlitespeed
yum install python3-devel 
yum install python3-pip
cd ~
curl -O http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.7.tgz

Output:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 48997  100 48997    0     0   130k      0 --:--:-- --:--:-- --:--:--  130k
[root@mail ~]# curl -O http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.7.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 48997  100 48997    0     0   135k      0 --:--:-- --:--:-- --:--:--  135k

Extract tar

tar xf wsgi-lsapi-1.7.tgz
cd wsgi-lsapi-1.7

Configure with Python 3

python3 ./configure.py

Compile

make

Output:

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o main.o main.c
In file included from /usr/include/inttypes.h:25:0,
                 from ./lsapidef.h:37,
                 from ./lsapilib.h:41,
                 from main.c:34:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o wsgi.o wsgi.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from wsgi.c:29:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o wsgiinput.o wsgiinput.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from wsgiinput.c:29:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o wsgiwrapper.o wsgiwrapper.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from wsgiwrapper.c:29:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o lsapilib.o lsapilib.c
In file included from /usr/include/ctype.h:26:0,
                 from lsapilib.c:35:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE              =2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64               -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -O0 -g3 -I. -I/usr/include/python3.6m  -I. -I/usr/inc              lude/python3.6m  -c -o lsapi-glue.o lsapi-glue.c
In file included from /usr/include/limits.h:26:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
                 from /usr/include/python3.6m/Python.h:11,
                 from lsapi-glue.c:33:
/usr/include/features.h:330:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimiz              ation (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
gcc -pthread -Wl,-z,relro  -g -L/usr/lib64 -Xlinker -export-dynamic -o lswsgi main.o wsgi.o wsgi              input.o wsgiwrapper.o lsapilib.o lsapi-glue.o -L/usr/lib64/python3.6/config-3.6m-x86_64-linux-gn              u -lpython3.6m -lpthread -ldl  -lutil -lm

Copy lswsgi to fcgi-bin

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

if existing overwrite

cp: overwrite ‘/usr/local/lsws/fcgi-bin/lswsgi’? y

Step 2 : Create site:

Login to your CyberPanel Control Panel.




Create website, you can get a new hosting account with Openlitespeed here https://www.hostingbyalitech.com

Fill out :

Site package : default (or any other if you have)

Site owner : yourusername

Domain name : souqagora.tk (here I am using this site this will be referred throughout the tutorial.

E-mail: your e-mail

Select php : 7.3 (this will not affect but normally I choose 7.3 or as required)

and check all additional features i.e. SSL, DKIM Support, open_basedir protection, Create Mail Domain

Step 3: Create Virtual Environment

Move to your site root dir:

cd /home/souqagora.tk/public_html

Create virtual environment:

python3 -m virtualenv /home/souqagora.tk/public_html

Output :

Using base prefix '/usr'
  No LICENSE.txt / LICENSE found in source
New python executable in /home/souqagora.tk/public_html/bin/python3
Also creating executable in /home/souqagora.tk/public_html/bin/python
Installing setuptools, pip, wheel...
done.

Activate virtual environment:

source /home/souqagora.tk/public_html

check python directory

which python

It should reflect the directory of your virtual environment:

/home/souqagora.tk/public_html/bin/python

Step 4: Install Django

pip install django

Output:

Collecting django
  Using cached Django-3.1.6-py3-none-any.whl (7.8 MB)
Collecting sqlparse>=0.2.2
  Using cached sqlparse-0.4.1-py3-none-any.whl (42 kB)
Collecting pytz
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting asgiref=3.2.10
  Using cached asgiref-3.3.1-py3-none-any.whl (19 kB)
Installing collected packages: sqlparse, pytz, asgiref, django
Successfully installed asgiref-3.3.1 django-3.1.6 pytz-2021.1 sqlparse-0.4.1

Step 5: Create Django Project

python3 -m django startproject souq

Note: My project name is souq replace as required.

Step 6: Modify Django settings

cd souq
cd souq
nano settings.py

Change below 

ALLOWED_HOSTS = []

So that it should reflect as:

ALLOWED_HOSTS = ['*']

and add below at the end of the file settings.py

STATIC_ROOT = '/home/souqagora.tk/public_html/souq/public/static'

mentioning /public/static is required

cd..

make sure you are in the below folder:

/home/souqagora.tk/public_html/souq/

Use this command to make sure:

pwd

create directory

mkdir -p public/static

Collect static files:

python manage.py collectstatic

Make database migration

python manage.py migrate

Output:

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK

Create super user:

python manage.py createsuperuser

Output:

Username (leave blank to use 'root'): root
Email address:
Password:
Password (again):
Superuser created successfully.

Note: Here I am creating with root user because I was having difficulties creating other users at the moment. After you create first user with root you may create other users while in Django admin.

Change folder owner:

chown -R nobody:nobody /home/souqagora.tk/public_html/souq/

Step 7: Create context in OpenLiteSpeed

Login to your OpenLiteSpeed Control Panel, 7080 is the Openlitespeed Port for Control Panel:

https://hostingbyalitech.com:7080

Go to Virtual Hosts on side bar.

and open the virtual host configuration form above icon.

Click Context Tab.

Click ‘+’ sign and add new context, select App Server as shown below:

and click next.

Now fillout these details as shown:

URI * = /

Location * = /home/souqagora.tk/public_html/souq/

Binary Path = /usr/local/lsws/fcgi-bin/lswsgi

Application Type = WSGI

Startup File = souq/wsgi.py

Environment = PYTHONPATH=/home/souqagora.tk/public_html/lib/python3.6:/home/souqagora.tk/public_html/souq
LS_PYTHONBIN=/home/souqagora.tk/public_html/bin/python

Note: Make sure you have python version 3.6 otherwise check accordingly and modify above version in PYTHONPATH.

Step 8: Verify Django Installation

http://souqagora.tk/admin/

These links were of help but I had to struggle alot to reach to success which changes have been included in these guides:

https://openlitespeed.org/kb/python-wsgi-applications/

https://blog.cyberpanel.net/2019/01/10/how-to-setup-django-application-on-cyberpanel-openlitespeed/

Keywords:

Install, Django, on, CyberPanel, Openlitespeed, with WSGI, WSGI, Install Django, CyberPanel Django, OpenLitespeed with WSGI

Posted in Technical Solutions on Feb 02, 2021



Ultimate Guide to Web Hosting and Domain Services: Everything You Need to Know

Posted in Uncategorized on Jun 28, 2024

Discover the ultimate guide to web hosting and domain services. Learn about domain name registration, secure WordPress hosting, dedicated Windows server hosting, and more. Find the best web hosting providers and services for your business needs



Hosting by AliTech listed in topmillion.net

Posted in About Hosting by AliTech, News on Feb 08, 2021

Top million domains by Alexa Hosting by AliTech listed in http://www.topmillion.net/domain-list-377



Free Backlinks by Guest posts on HostingbyAliTech

Posted in Hosting Promotions, News on Jan 26, 2021

Free Backlinks by Guest posts on HostingbyAliTech We are announcing an exciting news!!! Now you can get free backlinks just by creating account on HostingbyAliTech and creating guest post.



Understanding Next-Gen SDD Web Hosting and Its Benefits

Posted in Uncategorized on Jun 26, 2024

Discover the future of web hosting with Next-Gen SDD Web Hosting, featuring cutting-edge technology for enhanced speed and security. Learn how cPanel streamlines website management, and GMail Accounts enhance business communication. Additionally, explore the benefits of unlimited hosting plans, SFTP and SSL certificates for data security, Google G Suite for productivity, and web and app development for business growth. Finally, understand how SEO and SEM strategies optimize visibility, and digital marketing harnesses online potential.



Elon Musk’s xAI Plans to Create Video Games with an AI-Driven Studio

Posted in News on Nov 28, 2024

Elon Musk is expanding xAI's focus by venturing into video game development, aiming to challenge industry norms he finds overly corporate and politically influenced. Leveraging generative AI, Musk envisions creating innovative, immersive games while reducing development costs and timelines. With a deep-rooted passion for gaming and access to significant AI resources, Musk's bold initiative seeks to redefine game development, though it faces challenges in competing with established studios and navigating the high costs of AAA production.



11 Million Devices Infected with Botnet Malware Hosted in Google Play: A Detailed Overview

Posted in News on Sep 24, 2024

Recently, Necro malware has made headlines after infecting over 11 million devices through seemingly legitimate apps on Google Play, such as Wuta Camera and Max Browser. This malware utilizes advanced techniques like steganography, embedding malicious code within harmless-looking files to evade detection. Its modular design allows it to perform various malicious actions, including displaying intrusive ads and facilitating subscription fraud without users' knowledge. With the alarming resurgence of Necro, it’s crucial for users to remain vigilant, regularly update their security measures, and uninstall any suspicious applications to protect their devices from this sophisticated threat.



Google Now Offers Gemini App on iPhone

Posted in News on Nov 15, 2024

Google has launched a dedicated Gemini AI app for iPhone users, available for free in select countries. With features like Gemini Live, iPhone users can now interact with the AI assistant directly from the Lock Screen and Dynamic Island, allowing for easy access to conversational AI. While basic features are free, a Gemini Advanced subscription unlocks premium capabilities. The app is compatible with iPhones running iOS 16 and later, supports multiple languages, and offers a unique alternative to other AI voice assistants on iOS.



NASA Offers $3 Million Prize to Help Solve a Huge Problem in Moon Missions

Posted in News on Oct 18, 2024

NASA is gearing up for long-term missions on the Moon, but a significant challenge has surfaced—how to handle the waste produced in space. To address this, NASA is offering up to $3 million to those who can help solve this growing problem. The LunaRecycle Challenge aims to develop innovative waste management solutions that can reduce solid waste and enhance the sustainability of lunar missions.



OpenAI's Updated ChatGPT App for Mac: Revolutionizing Multitasking

Posted in Uncategorized on Aug 08, 2024

The recent update to OpenAI’s ChatGPT app for macOS introduces a transformative feature designed to enhance multitasking efficiency. This blog delves into the details of this update, exploring how it can streamline your workflow and improve overall productivity.



25 AI Tips to Boost Your Programming Productivity with ChatGPT

Posted in News on Nov 19, 2024

In today’s fast-paced programming environment, efficiency is key. With tools like ChatGPT, coding can become faster, smoother, and more effective. Think of AI as a trusty power tool in your development toolkit—it doesn’t build the project for you, but it makes the process much easier. Below, I’ll share 25 actionable tips to leverage ChatGPT and significantly enhance your programming productivity.



Ghost Framework: A Comprehensive Guide

Posted in Uncategorized on Sep 11, 2024

Ghost Framework is a powerful and flexible PHP framework designed for building robust and scalable web applications. With its modular design and MVC architecture, Ghost Framework enables developers to build applications in a structured and organized way. In this comprehensive guide, we'll explore the features and benefits of Ghost Framework, and provide a step-by-step tutorial on getting started with the framework. Whether you're a seasoned PHP developer or just starting out, Ghost Framework is an ideal choice for building fast, secure, and reliable web applications



US Election Results 2024: LIVE Updates on Trump's Lead in Key States

Posted in News on Nov 06, 2024

The 2024 US presidential election is becoming one of the most closely watched races in history. With former President Donald Trump facing Vice President Kamala Harris, early results indicate a tight race, especially in key battleground states. As the night unfolds, Trump leads in traditionally Republican states, but the outcome remains uncertain, with Nevada, North Carolina, and Georgia all still too close to call. Voters are anxiously awaiting final results, and Pennsylvania's outcome could very well determine the next president. Stay tuned for live updates on the election results and key developments.



How to Install Desktop Environment on CentOS 7 Oracle Cloud Instance

Posted in Technical Solutions on Feb 28, 2021

How to Install Desktop Environment on CentOS 7 Oracle Cloud Instance. This Orcle Cloud guide is also applicable Amazon AWS, Google Cloud and Microsoft Azure,etc



Firewall in Pakistan: Restricting Online Freedom and Access 2024

Posted in News on Aug 19, 2024

Pakistan's government is set to implement a nationwide firewall, sparking concerns about internet censorship and restrictions on online dissent. The firewall will monitor and control internet usage, targeting social media platforms and regulating VPNs. With a history of internet restrictions, this move raises questions about the future of free expression and democratic engagement in Pakistan. Key Points: Pakistan's national firewall will control access to social media platforms and monitor online activities The firewall aims to track and control internet usage, including VPNs Lack of transparency surrounding the project's scope and implications International concerns about the impact on freedom of expression and democratic principles Experts warn of potential risks to online privacy and security Read the full article to learn more about Pakistan's national firewall and its implications for internet freedom.



The Manifest Hails AliTech Solutions as One of the Most Reviewed IT Services Companies in Pakistan

Posted in About Hosting by AliTech on Jun 07, 2024

AliTech Solutions is proud to be recognized by The Manifest as one of the most reviewed IT services companies in Pakistan, showcasing our commitment to excellence and client satisfaction.



World of Quantum Computing and Its Effects on Web Hosting and Domain Names

Posted in Uncategorized on Jul 11, 2024

Quantum computing is no longer a concept confined to the realm of theoretical physics; it has entered the mainstream, promising to revolutionize various industries. Among these, web hosting and domain name management stand to benefit significantly from the advancements in quantum computing. Quantum computers can process large datasets more efficiently, enabling faster data retrieval and processing. This can significantly reduce the time it takes to load websites, improving the overall user experience. Moreover, quantum encryption techniques offer enhanced protection, ensuring that sensitive data transmitted over the internet remains secure from cyber threats. As quantum computing continues to evolve, it is set to transform web hosting and domain management, making them more efficient, secure, and reliable.



ACME now uses ZeroSSL, here is what you need to do for your CyberPanel

Posted in Technical Solutions on Jul 02, 2021

ACME now uses ZeroSSL, here is what you need to do for your CyberPanel.



Everything You Need to Know About Meta Connect 2024

Posted in News on Sep 23, 2024

Meta Connect 2024, happening from September 25 to 26, promises to be a groundbreaking event in the world of augmented and virtual reality. Attendees can expect exciting announcements, including the anticipated Quest 3S headset, which aims to offer a more affordable VR experience, and the innovative Orion AR glasses designed for seamless augmented reality interactions. In addition to hardware, the conference will highlight advancements in artificial intelligence, potentially unveiling an upgraded version of the Llama language model to enhance user experiences across Meta’s platforms. With live-streamed keynotes and developer sessions, Meta Connect 2024 is set to shape the future of technology and the metaverse, making it a must-watch event for enthusiasts and developers alike.




Other Blogs


Hosting by AliTech listed in topmillion.net

Posted in About Hosting by AliTech, News on Feb 08, 2021 and updated on May 14, 2021

Free Backlinks by Guest posts on HostingbyAliTech

Posted in Hosting Promotions, News on Jan 26, 2021 and updated on Mar 30, 2022

Understanding Next-Gen SDD Web Hosting and Its Benefits

Posted in Uncategorized on Jun 26, 2024 and updated on Jun 26, 2024

Elon Musk’s xAI Plans to Create Video Games with an AI-Driven Studio

Posted in News on Nov 28, 2024 and updated on Nov 28, 2024

Google Now Offers Gemini App on iPhone

Posted in News on Nov 15, 2024 and updated on Nov 15, 2024

NASA Offers $3 Million Prize to Help Solve a Huge Problem in Moon Missions

Posted in News on Oct 18, 2024 and updated on Oct 18, 2024

OpenAI's Updated ChatGPT App for Mac: Revolutionizing Multitasking

Posted in Uncategorized on Aug 08, 2024 and updated on Aug 08, 2024

25 AI Tips to Boost Your Programming Productivity with ChatGPT

Posted in News on Nov 19, 2024 and updated on Nov 19, 2024

Ghost Framework: A Comprehensive Guide

Posted in Uncategorized on Sep 11, 2024 and updated on Sep 11, 2024

US Election Results 2024: LIVE Updates on Trump's Lead in Key States

Posted in News on Nov 06, 2024 and updated on Nov 06, 2024

Firewall in Pakistan: Restricting Online Freedom and Access 2024

Posted in News on Aug 19, 2024 and updated on Aug 19, 2024

Everything You Need to Know About Meta Connect 2024

Posted in News on Sep 23, 2024 and updated on Sep 23, 2024

Google Now Offers Gemini App on iPhone

Posted in News on Nov 15, 2024

Google Now Offers Gemini App on iPhone

Posted in News on Nov 15, 2024







Comments

Please sign in to comment!






Subscribe To Our Newsletter

Stay in touch with us to get latest news and discount coupons