Difference between revisions of "Modules:PageSpeed"
From OpenLiteSpeed Wiki
Marmstrong (talk | contribs) |
Marmstrong (talk | contribs) (→Build modpagespeed.so) |
||
Line 22: | Line 22: | ||
=== Build <code>modpagespeed.so</code> === | === Build <code>modpagespeed.so</code> === | ||
− | + | <pre>make</pre> | |
− | |||
− | <pre>make | ||
'''Note:''' If compiling does not work, try <code>gmake</code> instead of <code>make</code>. | '''Note:''' If compiling does not work, try <code>gmake</code> instead of <code>make</code>. |
Revision as of 20:01, 3 October 2014
This wiki discusses how to add and configure OpenLiteSpeed's PageSpeed module. The PageSpeed module allows OpenLiteSpeed to support Google's PageSpeed optimization system.
For this guide, we assume you already have a working installation of OpenLiteSpeed 1.4.2 or higher. Module support is available in versions 1.3 or higher, but the PageSpeed module is only available and supported starting with version 1.4.2. The PageSpeed module is not added to OpenLiteSpeed installations automatically and so must be built.
Note: PageSpeed Optimization Libraries (PSOL) are only available for Linux and thus OpenLiteSpeed's PageSpeed Module is only available for Linux.
Contents
- 1 Building the LiteSpeed PageSpeed module
- 2 Registering the module
- 3 Test
- 3.1 Add the Lua module as a script handler by going to WebAdmin console > Configuration > Server > Script Handler > Add
- 3.2 Specify Suffix "lua", Handler Type "Module Handler", Handler Name "mod_lua"
- 3.3 Save the script handler settings
- 3.4 Create a Lua script hello.lua in a virtual host html directory
- 3.5 Run the Lua script from a browser
- 4 Configuration
Building the LiteSpeed PageSpeed module
Download OpenLiteSpeed 1.4.2 and install or higher if you have not done so
The PageSpeed Module is available starting with OpenLiteSpeed version 1.4.2.
Add PSOL
The PageSpeed Optimization Libraries (PSOL) are a set of C++ classes that automatically optimize web pages.
Go into the PageSpeed Module's directory (/openlitespeed_download/src/modules/pagespeed
) and run ./ccc.sh
to get the latest version of PSOL supported by OpenLiteSpeed. Do not use other versions of PSOL as they may not be supported by OpenLiteSpeed.
cd /openlitespeed_download/src/modules/pagespeed ./ccc.sh
Build modpagespeed.so
make
Note: If compiling does not work, try gmake
instead of make
.
Move the dynamic library to your modules directory
cp modpagespeed.so /usr/local/lsws/modules
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"
Set parameters
A number of user parameters may be specified. Most important 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.
The default for the lib parameter is:
lib /usr/local/lib/libluajit.so
If the LuaJIT library is located somewhere else, if can be set as follows:
lib /home/user/LuaJIT-2.0.3/src/libluajit.so
Save the module settings
Restart the server
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.
Test
The Lua module executes Lua scripts as a script handler. By convention, Lua scripts are designated with suffix lua
.
Add the Lua module as a script handler by going to WebAdmin console > Configuration > Server > Script Handler > Add
Specify Suffix "lua", Handler Type "Module Handler", Handler Name "mod_lua"
Save the script handler settings
NOTE: Make sure after any configuration change the server is restarted.
Create a Lua script hello.lua
in a virtual host html directory
ls.say(ls.logtime(), "LiteSpeed: Hello", _VERSION)
The default OpenLiteSpeed installation sets up a Virtual Host named Example
mapped to Listener Default
at Port 8088 with various files in its html
subdirectory. Put the test Lua script here.
Run the Lua script from a browser
or alternatively, use curl
:
user@host> curl -k -i http://localhost:8088/hello.lua HTTP/1.1 200 OK Content-Length: 56 Date: Wed, 16 Jul 2014 15:08:16 GMT Server: LiteSpeed Wed 16 Jul 2014 11:08:16 -0400 LiteSpeed: Hello Lua 5.1
Configuration
Parameters in the WebAdmin Console
- lib = The location of the LuaJIT library. (Default =
/usr/local/lib/libluajit.so
) - maxruntime = The maximum script runtime in millisec. (Default = 0, no limit)
Inheritance
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.
Other
Always leave Enable Hooks Not Set or it will break things (not disable at vhost level).