Actions

Help

Difference between revisions of "Modules:PageSpeed"

From OpenLiteSpeed Wiki

(Registering the module)
Line 50: Line 50:
 
pagespeed RewriteLevel CoreFilters</pre>
 
pagespeed RewriteLevel CoreFilters</pre>
  
Configuration  
+
Configuration is covered in more detail in the [[#Configuration|configuration]] section.
  
 
=== Save the module settings ===
 
=== Save the module settings ===
Line 58: Line 58:
 
=== Restart the server ===
 
=== Restart the server ===
  
[[File:Lua_Mod_Restart.png|600px|thumb|center]]
+
[[File:PageSpeed_Mod_Restart.png|600px|thumb|center]]
 
 
=== 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|Configuration section]] below.
 
  
 
== Test ==
 
== Test ==
  
The Lua module executes Lua scripts as a script handler. By convention, Lua scripts are designated with suffix <code>lua</code>.
+
Google offers test files to test your PageSpeed support.
 
 
=== Add the Lua module as a script handler by going to WebAdmin console > Configuration > Server > Script Handler > Add ===
 
 
 
[[File:Lua_Mod_ShAdd.png|600px|thumb|center]]
 
 
 
=== Specify Suffix "lua", Handler Type "Module Handler", Handler Name "mod_lua" ===
 
 
 
[[File:Lua_Mod_ShName.png|600px|thumb|center]]
 
 
 
=== Save the script handler settings ===
 
 
 
[[File:Lua_Mod_ShSave.png|600px|thumb|center]]
 
 
 
'''NOTE''': Make sure after any configuration change the server is [[#Restart the server|restarted]].
 
 
 
=== Create a Lua script <code>hello.lua</code> in a virtual host html directory ===
 
 
 
<pre>
 
ls.say(ls.logtime(), "LiteSpeed: Hello", _VERSION)
 
</pre>
 
The default OpenLiteSpeed installation sets up a Virtual Host named <code>Example</code> mapped to Listener <code>Default</code> at Port 8088 with various files in its <code>html</code> subdirectory. Put the test Lua script here.
 
 
 
=== Run the Lua script from a browser ===
 
 
 
[[File:Lua_Mod_Run.png|600px|thumb|center]]
 
 
 
or alternatively, use <code>curl</code>:
 
 
 
<pre>
 
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
 
</pre>
 
  
 
== Configuration ==
 
== Configuration ==
  
=== Parameters in the WebAdmin Console ===
+
Configuration of OpenLiteSpeed's PageSpeed Module follows the syntax outlined in Google's documentation for the NGINX module. The one difference is that lines should not end with a semicolon (<code>;</code>).
 
 
* lib = The location of the LuaJIT library. (Default = <code>/usr/local/lib/libluajit.so</code>)
 
* maxruntime = The maximum script runtime in millisec. (Default = 0, no limit)
 
  
=== Inheritance ===
+
=== Important Parameters ===
  
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.
+
* pagespeed on/off = This parameter turns PageSpeed on or off at the server or virtual host level.
 +
* pagespeed FileCachePath = Determines the location of the PageSpeed cache. (If this directory does not exist, OpenLiteSpeed will create it.)
 +
* pagespeed RewriteLevel CoreFilters = CoreFilters is a set of filters that the Google PageSpeed team believes are safe for most websites. The CoreFilters set is dynamically updated.
  
=== Other ===
+
=== Further configure the module at the virtual host level ===
  
Always leave Enable Hooks Not Set or it will break things (not disable at vhost level).
+
The PageSpeed Module can be further configured at the virtual host level. (Google does not support context- and script handler-level configurations.) Virtual host-level configurations will always override server level-configurations.
  
Don't use with Cache. PageSpeed has its own cache.
+
'''Note:''' Always leave the Enable Hooks setting as "Not Set". Setting it to "No" will not disable PageSpeed at the virtual host level and may cause unpredictable functionality. To disable PageSpeed at the virtual host level, use <code>pagespeed off</code> in the virtual host-level module parameters.
  
 +
==== Note ====
  
 +
Do not use with the PageSpeed Module with OpenLiteSpeed's Cache Module. PageSpeed has its own cache and using the two modules together may cause unpredictable functionality.
  
 
[[Category:Help]] [[Category:Modules]]
 
[[Category:Help]] [[Category:Modules]]

Revision as of 21:06, 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.

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

Setting up the module

Add the PageSpeed Module by going to WebAdmin console > Configuration > Server > Modules > Add

PageSpeed Mod Add.png

Enter the name of the module as "modpagespeed"

PageSpeed Mod Name.png

Set parameters

PageSpeed Mod Param.png

PageSpeed may be configured using a variety of settings and filters. The following are some default parameters:

pagespeed on
pagespeed FileCachePath /tmp/lshttpd/pagespeed
pagespeed RewriteLevel CoreFilters

Configuration is covered in more detail in the configuration section.

Save the module settings

PageSpeed Mod Save.png

Restart the server

Test

Google offers test files to test your PageSpeed support.

Configuration

Configuration of OpenLiteSpeed's PageSpeed Module follows the syntax outlined in Google's documentation for the NGINX module. The one difference is that lines should not end with a semicolon (;).

Important Parameters

  • pagespeed on/off = This parameter turns PageSpeed on or off at the server or virtual host level.
  • pagespeed FileCachePath = Determines the location of the PageSpeed cache. (If this directory does not exist, OpenLiteSpeed will create it.)
  • pagespeed RewriteLevel CoreFilters = CoreFilters is a set of filters that the Google PageSpeed team believes are safe for most websites. The CoreFilters set is dynamically updated.

Further configure the module at the virtual host level

The PageSpeed Module can be further configured at the virtual host level. (Google does not support context- and script handler-level configurations.) Virtual host-level configurations will always override server level-configurations.

Note: Always leave the Enable Hooks setting as "Not Set". Setting it to "No" will not disable PageSpeed at the virtual host level and may cause unpredictable functionality. To disable PageSpeed at the virtual host level, use pagespeed off in the virtual host-level module parameters.

Note

Do not use with the PageSpeed Module with OpenLiteSpeed's Cache Module. PageSpeed has its own cache and using the two modules together may cause unpredictable functionality.