Wikka Documentation : LighttpdConfig

HomePage :: Index :: RecentChanges :: Search :: Login/Register

Configuring Lighttpd for Wikka

See also:


I recently got Wikka running under lighttpd, and since I was only able to find limited documentation to support that effort either here or elsewhere, I thought I should document my experience for posterity.

Before I get started, though, I need to acknowledge JavaWoman and LadySerena from #wikka, both for their assistance in getting the URL rewriting working, and for encouraging me to record the results.

Server Configuration

For my particular installation, I wanted to serve Wiki content out of the document root for a dedicated subdomain. So rather than have my Wiki reside at, say, http://www.example.com/wiki, I wanted it at http://wiki.example.com/. I also wanted it to use user-friendly URLs, like http://wiki.example.com/HomePage, rather than the out-of-the-box query-string URLs, such as http://wiki.example.com/wikka.php?wakka=HomePage. Finally, to get the best performance out of the combination of lighttpd and PHP, I chose to interface them using FastCGI.

To that end, I unpacked the Wikka distribution into the directory I had selected for my subdomain's document root, and then set about editing my lighttpd.conf configuration file.

Lighttpd Configuration

With respect to the server.modules configuration parameter, you will need to include mod_fastcgi for FastCGI support and, if you want user-friendly URLs, mod_rewrite. You should also make sure the index.php is included among the values for the server.indexfiles configuration parameter.

The server.modules configuration parameter applies to your overall lighttpd installation. If you're running multiple PHP applications, then adding index.php to the global server.indexfiles value is fine. If not, it could alternatively be set in a hostname-specific value for server.indexfiles.

All of the remaining configuration values are hostname-specific, since they apply only to the hostname that is running Wikka. Here's what the hostname-specific settings should look like:
$HTTP["host"] =~ "wiki\.example\.com" {
  server.document-root = "/full/path/to/wiki/root/"
  fastcgi.server = ( ".php" =>
			( "localhost" =>
			  ( "socket" => "/tmp/wikkawiki.socket",
				"max-procs" => 2,
				"bin-path" => "/full/path/to/php-cgi",
				"bin-environment" =>
				( "PHP_FCGI_CHILDREN" => "2",
				  "PHP_FCGI_MAX_REQUESTS" => "5000"
  url.rewrite-once = (
			"^(/images/.*)$" => "$1",
			"^(/css/.*)$" => "$1",
			"^(/3rdparty/plugins/freemind/.*)$" => "$1",
			"^(/3rdparty/plugins/wikiedit/.*)$" => "$1",
			"^(.*)$" => "wikka.php?wakka=$1"

Of these, the values for the hostname, the document root, the socket file, and the path for the CGI script will need to be customized for your installation. You may also want to tweak the "max-procs" and "bin-environment" values, based on the expect load and the available server resources.

The hostname is specified in the first line, as a regular expression. In the example above, the hostname value is "wiki\.example\.com", where backslashes are used to indicate literal period characters.

The document root is specified via the server.document-root parameter, and its value should be the full pathname for the directory from which your top-level web pages are to be served. In my case, this is the directory in which Wikka was installed, since I am mapping the hostname directly to my Wiki. If your hostname provides other content in addition to your Wiki, then your server.document-root value will need to point to one of the parent directories of your Wikka installation (i.e., whichever serves as the overall document root for that hostname).

The socket file is a temporary file used for facilitating communication between lighttpd and the Wikka PHP application. The value for the "socket" parameter needs to be a filename that both of these processes have permission to access. If you have a dedicated server for your website, then something in the global /tmp directory (as in the example here) should be fine. If you are using a shared host, however, you should probably create a subdirectory somewhere under your home directory that can contain the socket file, to make sure there is no conflict with other users on the shared host.

Finally, the value of the "bin-path" parameter indicates where the CGI script for PHP resides. This is typically in a directory on the web server that is dedicated to CGI scripts, often named cgi-bin. On my hosting provider's server, for example, that directory is named /usr/local/www/cgi-bin/. The specific script will typically include both php and cgi in its name, and may also indicate a specific version of PHP. There may also be a script that is specifically geared towards FastCGI, in which case the script's name will probably include fcgi rather than just cgi. Potential values include php-cgi, php4-cgi, and php5-fcgi. The value for "bin-path" should be the full path name to the script, so /usr/local/www/cgi-bin/php5-fcgi would be a valid example.


The Gentoo Linux Wiki has a good overview of configuring Lighttpd for PHP applications. Some of the material, such as installation utilities and paths, is specific to Gentoo, but adapting this information to other Unix-based operating systems should be pretty straightforward.

With respect to URL rewriting, the information on this Wiki regarding configuration of Apache's mod_rewrite module for Wikka was a good reference for understanding the requirements that I needed to match in lighttpd.

There is one comment on this page. [Display comment]
Creative Common Attribution-ShareAlike License
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0103 seconds