• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

LiteSpeed: Enable Python application execution

Mithun S.

  • 7 min read
LiteSpeed: Enable Python application execution

Generating audio, please wait...

LiteSpeed should process PHP files when we install LiteSpeed as all the configuration settings are present by default. As for python scripts, it’s required to be manually enable python done. We’re going to see how to enable python application on LiteSpeed Web Server assuming python is already installed and it’s working fine.

Requirement : LiteSpeed Version greater than 4.2.4

Python LSAPI Installation

Downloading and compiling the module.

cd /usr/local/lsws/

Download the WSGI LSAPI module:

wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.0.tgz

tar -xvf wsgi-lsapi-1.0.tgz cd wsgi-lsapi-1.0/

python ./configure.py

make

mv lswsgi /usr/local/lsws/fcgi-bin/ (this directory contains all the LSAPI binaries)

First we’ll see how to get into the LiteSpeed control panel (WebAdmin Console). It’s a centralized control panel to control and configure all LiteSpeed Web Server settings.

Login to WHM of the server.

Select ‘LiteSpeed Web Server‘ under Plugins

Click on the ‘LiteSpeed Configuration’ and then ‘WebAdmin Console’

Enter your LiteSpeed admin username and password.

 

From Configuration select Server

litespeed_admin

Now we need to set up an external application and script handler.

Set up an external application

External App : LiteSpeed web server can forward requests to external applications to process and generate dynamic content. Since 2.0, LiteSpeed Web Server has supported seven types of external applications: CGI, FastCGI, web server, servlet engine, LiteSpeed SAPI application, load balancer, and piped logger.

Go to the External App tab from the console.

WebAdmin console » Configuration » External App and click Add.

litespeed2

Add a new app with Type as LSAPI App

litespeed_app_add

Give the new app a name. In this case it’s ‘lspython’.

lspython

The important thing you need to specify is for the option ‘Command’. It tells which binary to execute so as to launch the processes. You need to specify the full path with the binary file: /usr/local/lsws/fcgi-bin/lswsgi

lswsgi

You need to specify values for Max Connections, Initial Request Timeout, and Retry Timeout.

You can refer the one’s for PHP app, if you are not sure about on what values to input as PHP app is enabled by default when installing LiteSpeed. Click ‘Save’.

Now we have an LSWSGI external application ‘lspython’. Now we need to create a script handler for the app we’ve created.

script_handler

Set up the script handler

Script Handler : LiteSpeed Web Server supports all scripting languages including Perl, PHP, Ruby, Python, Java, etc. Scripts written in these different languages must be brought to the appropriate external application to be processed. LiteSpeed Web Server uses script handlers to decide which external application a script should go to. These script handlers map files to external applications by using the file suffix. (Actually, the suffix is used to determine a MIME type which is then mapped to the external application.) External applications must be set up in the {PAGE= ExtApp_Help} tab before they can be selected for use in a script handler. You can set up script handler at the server or virtual host level. Server-level script handlers apply to all virtual hosts unless overridden in virtual host level. Virtual host-level script handlers only apply within that virtual host.

Go to the Script Handler tab from the console.

WebAdmin console » Configuration » Script Handler and click Add.

litespeed_webserver

You need to specify ‘wsgi’ as the suffix. For Handler Type select LiteSpeed SAPI and for Handler Name choose the LSWSGI external application (lspython) we’ve just created. So any python script with .wsgi sufix will get executed.

litespeed_sapi

Click ‘Save’ and now we’ve a handler for our app ‘[Server Level]: lspython‘.

ls_pythn

Graceful restart LSWS to apply changes. Now the LiteSpeed Web Server should be able to handle .wsgi scripts.

/scripts/restartsrv_apache

If you need to execute a different script with suffix, for eg: .py , you need to add another handler with extension as ‘py’. But it seems suEXEC mode won’t get enabled if we are using a different extension other than ‘wsgi’ assuming it’s a bug or something in their WSGI LSAPI module, the processes will be launched under the ownership of ‘nobody’ user. So it’s recommended to create the handler with suffix as just ‘wsgi’.

But most of the python scripts should have .py extension, so we need to either specify the extension in the configuration file or need to mention it in .htaccess file so as to get executed in suEXEC mode itself.

To add in the configuration file.

vi /usr/local/apache/conf/httpd.conf

Add the below code somewhere on the file:

AddType application/x-httpd-wsgi .py

This should execute the .py extensions via the wsgi handler which we’ve created.

Graceful restart LSWS to apply changes.

/scripts/restartsrv_apache

You can also specify the extension in the .htaccess file in the document root where you are trying to execute the script.

AddType application/x-httpd-wsgi .py

Now let’s test this to see if python scripts are getting executed. Here we’re using a simple Hello World python script.

def application(environ, start_response): status = '200 OK' output = 'Hello World' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]

We’ll save this script as python.py to the document root of any test domain. Now when we try to access the file in a browser, it should work fine and display our ‘Hello World’

References:

http://www.litespeedtech.com/docs/litespeed-sapi/python-lsapi/installation

http://www.litespeedtech.com/docs/litespeed-sapi/python-lsapi/configuration

  • cPanel
  • Howtos
  • Linux

cPanel addon domain creation: ‘The domain already exists in the Apache configuration.’

cPanel addon domain creation: ‘The domain already exists in the Apache configuration.’
  • cPanel
  • Howtos
  • Troubleshooting
logo

cPHulk: IP block removal

cPHulk: IP block removal
  • Howtos
  • MySQL
  • Troubleshooting
logo

How to configure timezone in Ubuntu

How to configure timezone in Ubuntu
  • General
  • Howtos
  • Linux
logo

Image upload through WordPress shows “Missing Temporary Folder”

Image upload through WordPress shows  “Missing Temporary Folder”
  • General
  • Howtos
  • Linux
  • Troubleshooting
logo
LiteSpeed: Enable Python application execution

Posts by Mithun S.

Mithun S.