Python LSAPI Administration

Using Apache Configurations

With the Python LSAPI module, LiteSpeed Web Server can automatically detect and utilize settings for existing Python applications using mod_wsgi. No change should be necessary to bring in an application from Apache.

Using Native LiteSpeed Configurations

Python applications can be set up with LSAPI using the same methods used with any other LSAPI application — by setting up an external application and script handler in the WebAdmin console.

  1. Setting up an external application:
    1. Go to the External App tab (WebAdmin console > Configuration > External App) and add an external application. (This can be done at the server or virtual host level.)
    2. Set Type to "LSAPI App"
    3. Give your external application a name and a socket. Most importantly, for the Command setting, specify the location of the lswsgi executable: "/usr/local/lsws/fcgi-bin/lswsgi". (You also have to pick values for Max Connections, Initial Request Timeout, and Retry Timeout.)
  2. Setting up a script handler:
    A WSGI script handler will tell LSWS to send .wsgi scripts to the LSWSGI application.
    1. Go to the Script Handler tab (WebAdmin console > Configuration > Script Handler) and click Add. (This, also, can be done at the server or virtual host level.)
    2. Set Suffix to ".wsgi" (the suffix of my WSGI Python apps). Set Handler Type to "LiteSpeed SAPI". For Handler Name, choose the LSWSGI external application just created.
  3. Graceful restart to apply changes.


suEXEC is usually preferred in the shared hosting environment. LSWS will start a Python WSGI application in suEXEC mode (running as the same user ID as the site owner) when the PHP suEXEC setting is enabled (WebAdmin console > Configuration > General). It will follow the same security model used for PHP. For each account, the maximum concurrent processes follows the PHP suEXEC Max Conn setting (WebAdmin console > Configuration > General).

The default settings for the Python LSAPI, though, only set up suEXEC for for applications with the suffix .wsgi. If you need Python LSAPI to run scripts with other suffixes in suEXEC, there are two ways to set this up:

  1. For Apache configurations: Create a script handler for the suffix .wsgi, then add the directive AddType application/x-httpd-wsgi .yoursuffix to this script handler.
  2. For native LiteSpeed configurations: Add a comma and your suffix after ".wsgi" in step 2ii above. (Example: ".wsgi, .py") ".wsgi" must be the first suffix in order for this to work.