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.
- Setting up an external application:
- 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.)
- Set Type to "LSAPI App"
- Give your external application a name and a socket. Most importantly, for the Command setting, specify the location of the
lswsgiexecutable: "/usr/local/lsws/fcgi-bin/lswsgi". (You also have to pick values for Max Connections, Initial Request Timeout, and Retry Timeout.)
- Setting up a script handler:
A WSGI script handler will tell LSWS to send
.wsgiscripts to the LSWSGI application.
- 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.)
- 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.
- 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:
- For Apache configurations: Create a script handler for the suffix
.wsgi, then add the directive
AddType application/x-httpd-wsgi .yoursuffixto this script handler.
- 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.