From OpenLiteSpeed Wiki
Revision as of 21:44, 15 July 2014 by Peter (Created page with "This wiki will go over adding and configuring OpenLiteSpeed's Lua module (mod_lua). Using this module, OpenLiteSpeed offers a convenient and efficient interface to the proven,...")
This wiki will go over adding and configuring OpenLiteSpeed's Lua module (mod_lua). Using this module, OpenLiteSpeed offers a convenient and efficient interface to the proven, fast, powerful scripting language, Lua.
For this guide, we assume you already have a working installation of OpenLiteSpeed 1.4.0 or higher. Module support is available in versions 1.3 or higher. The Lua module is available starting with version 1.4.0. If the
mod_lua.so dynamic library is not in the OpenLiteSpeed
modules directory, the Lua module must be built.
- 1 Loading LuaJIT
- 2 Building the LiteSpeed Lua module
- 3 Registering the module
- 4 Configuration
LuaJIT is a Just-In-Time Compiler for the Lua programming language. This open source software provides LiteSpeed's interface to Lua. If the LuaJIT library
libluajit.so is not currently installed, you should download the current version from http://luajit.org. Follow the installation instructions from this site. Note, however, that for LiteSpeed execution, the only necessary component of LuaJIT is
Building the LiteSpeed Lua module
Download OpenLiteSpeed 1.4.0 if you have not done so
The Lua module is available starting with OpenLiteSpeed version 1.4.0.
Install OpenLiteSpeed with Lua
There are some special considerations when building and installing LiteSpeed with the Lua module. If installing a complete system from download, an additional parameter must be specified to LiteSpeed's configure program to indicate Lua module compilation and where the LuaJIT header files exist.
If header files are in a standard directory:
./configure --with-lua=yes ...
Else to specify the directory (recommended); e.g., /home/user/LuaJIT-2.0.3/src:
./configure --with-lua=/home/user/LuaJIT-2.0.3/src ...
Remaking the Lua module separately
The general steps for adding modules are covered in the guide to registering a module. However, there are some special considerations when building the Lua module.
Registering the module
Add the Lua module by going to WebAdmin console > Configuration > Server > Modules > Add
Enter the name of the module as "mod_lua"
A number of user parameters may be specified. Most importantly is the location of the LuaJIT library
libluajit.so if not in the default
/usr/local/lib/ directory. Configuring these settings will be covered in the Configuration section below.
lib /usr/local/lib/libluajit.so lib /home/user/LuaJIT-2.0.3/src/libluajit.so
Save the module settings
Further configure the module at different levels
The module can be further configured at the virtual host, context, and script handler levels. More specific levels of configuration will always override more general levels. For example, virtual host-level configurations override server-level configurations and context-level configurations override virtual host-level configurations. Configurations are covered in the Configuration section below.
View headers on cacheable pages. A page served from public cache will display the header
X-LiteSpeed-Cache: hit. A page served from private cache will display the header
X-LiteSpeed-Cache: hit, private.
Parameters in the WebAdmin Console
- lib = The location of the LuaJIT library. (Default =
All modules must be registered at the server level. Once a module is registered, it's settings are inherited by more specific setting levels (virtual host, context, and script handler). Configurations can be modified at these more specific levels. Settings at more specific levels always override more general levels. For example, virtual host-level configurations override server-level configurations and context-level configurations override virtual host-level configurations.