SSI.cgi: A standalone Server Side Includes parser

Using SSI.cgi

NOTE: FastCGI support was removed in v1.8

For the CGI version, the first parameter is the SSI file to parse, and subsequent parameters are treated as option switches. The FastCGI version does not have any required parameters and treats parameters as option switches. The following option switches are accepted by both versions:

Files included using file= or docroot= are not parsed for SSI directives, instead as simply copied verbatim. Potentially a major performance gain where SSI files are relativly small 'wrappers' that assemble large static files into a single page.
Error messages will not be sent to stderr. Useful if you are running SSI.cgi from the commandline, don't want SSI messages polluting your server logs, or your webserver doesn't handle stderr properly.
When an error occurs, users will see a detailed error message similar to what is sent to the server logs via stderr, rather than the normal generic "There was an error" message. Useful as seeing error messages via the web browser makes tracing errors easier, but it may be undesirable on production servers.
Allows the use of ../ within file and docroot parameters. A useful feature if you trust all your server's users. Disabled by default as Apache SSI seems to regard it as a security hazard.
The following option switches are only accepted by the (deprecated) FastCGI version:
--port PORT
Bind to given port, rather than expecting the webserver to have setup a socket for SSI.fcgi. If --interface is absent, ssi.fcgi will only allow connections from localhost.
--interface IP
Specify an interface to bind to. Requires --port to be specified
Handle connections serially rather than forking each connection to its own thread. Assumes the server process creates multiple instances and load balances between them.

Webserver setup

Note: These instructions are now rather dated, and in the case of Cherokee are likley outright wrong by now..


To setup for use in
Cherokee, use the phpcgi handler. Despite its name, phpcgi is actually a generic generic interpreter interface:

Extension shtml {
 Handler phpcgi {
   Interpreter /usr/local/bin/ssi.cgi

See Cherokee's phpcgi documentation for further details. To use FastCGI, use Cherokee's FastCGI handler:

 Extension shtml {
  Handler fcgi {
     Server localhost:9999 {
     Interpreter "/usr/local/bin/ssi.fcgi --port 9999"

See Cherokee's FastCGI documentation for further details.


For lighttpd you need to enable the cgi (or fastcgi module). This is done by uncommenting the relevent part of server.modules in the lighttpd config file:

server.modules = ( "mod_access","mod_fastcgi","mod_cgi","mod_accesslog" )

You then need to assign SSI.cgi as a 'handler' for SSI files. For standard CGI this is quite easy:

cgi.assign = ( ".shtml" => "/usr/local/bin/ssi.cgi" )

For FastCGI it is a similar directive:

fastcgi.server =
( ".shtml" =>
  (( "host" => "", "port" => 9999,
     "bin-path" => "/usr/local/bin/ssi.fcgi"