Falcon is Web Framework written in Python.
You can run it using wsgi. Openlitespeed supports wsgi and virtualenv. Lets set it up.
1. Install lswsgi
lswsgi is wsgi for Openlitespeed.
In below link, complete up to and including “Install WSGI”.
Make sure to get latest lswsgi bin from here:
2. Create virtualenv and install falcon
3. Create sample wsgi.py script
Openlitespeed will by default look for wsgi.py script (you can change this if you want to in Context setting).
Also, it will try invoking
application instance in wsgi.py script. So you must have your wsgi web instance named
application in your python script.
wsgi.py will have below content:
4. Setup lswsgi
Access to lsws admin console.
You can use either server configuration or vhost configuration.
I’m going to use vhost with vhost root at
/srv/vhadm and document root at
vhost Basic Tab
Make sure “Enable Scripts/ExtApps” setting is enabled.
vhost General Tab
vhost Context Tab
Open context tab and click on plus button. Select App Server. Next.
Define as below:
URI = / Location = $DOC_ROOT Binary Path = <path-to-lswsgi> eg: /usr/local/lsws/fcgi-bin/lswsgi Application Type = WSGI Environment = LS_PYTHONBIN=/srv/vhadm/venv/bin/python
Save the changes.
NOTE: the lsws instruction page tells you to also set PYTHONPATH in Environment but this is not required as python searches packages by traversing back from its binary path.
5. Check file permission
In my setup, since
External App Set UID Mode is Not Set in vhost configuration, it will use lsws user to run the script.
Change the file ownership so that lsws user can at least read the wsgi.py file.
In my case, lsws user is
6. Configure listener to that vhost and graceful restart the lsws
7. Test if it works correctly
Sample script only accepts endpoint “/things”.
So to test, you will use below url:
You should receive response with body “Hello World” if successful.