From Observium
Contents |
Lighttpd and Observium
This example uses Debian Squeeze but should work on any Debian based distribution and can be easily adapted for other Distros/OS's. Lighttpd is NOT officially supported by Observium...this is known to work, but the Observium Team recommends Apache instead.
Please note that this list is from the Installation Page but instead of libapache2-mod-php5...lighttpd is added. Apache files are not required when using lighttpd.
First make sure you have the prerequisite packages installed below.
aptitude install lighttpd php5-cli php5-mysql php5-gd php5-snmp \ php-pear snmp graphviz subversion mysql-server mysql-client rrdtool \ fping imagemagick whois mtr-tiny nmap ipmitool
Enable the necessary modules
lighty-enable-mod fastcgi lighty-enable-mod fastcgi-php
You need to add this to the bottom of your php.ini file
echo "cgi.fix_pathinfo = 1" > /etc/php5/cgi/php.ini
You also need to edit your /etc/lighttpd/lighttpd.conf and change this
# "mod_rewrite"
To this
"mod_rewrite"
Final Steps
Now on to the secret sauce...the rewrite rules. This solution will not work without these rules.
Observium's Apache rewrite rules were modified to work with Lighttpd by iksaif
You should only edit the two top lines of the rewrite rules unless you know what you're doing!
$HTTP["host"] == "observium.example.com" {
server.document-root = "/opt/observium/html"
Change "observium.example.com" to your hostname or ipaddress "
Change "/opt/observium/html" to your Observium webroot:
You need to add these to your /etc/lighttpd/lighttpd.conf or anywhere that works for you ie an include , shown below in the Optional Section.
Rewrite rules
$HTTP["host"] == "observium.example.com" {
server.document-root = "/opt/observium/html"
url.rewrite-once = (
"^/(.*)\.(png|css|jpg|gif|php)$" => "/$0",
"^/cust/" => "/?page=cust",
"^/bare/(.+)/" => "/index-bare.php?page=$1",
"^/bare/(.+)/(.+)/" => "/index-bare.php?page=$1&opta=$2",
"^/bare/(.+)/(.+)/(.+)/" => "/index-bare.php?page=$1&opta=$2&optb=$3",
"^/mobile/([a-z|0-9]+)/(.+)/(.+)/" => "/mobile.php?page=$1&opta=$2&optb=$3",
"^/mobile/([a-z|0-9]+)/(.+)/" => "/mobile.php?page=$1&opta=$2",
"^/mobile/([a-z|0-9]+)/" => "/mobile.php?page=$1",
"^/mobile/" => "/mobile.php",
## Rewrites for Devices
"^/devices/location/(.+)/" => "/?page=devices&location=$1",
"^/devices/alerted/" => "/?page=devices&status=alerted",
"^/devices/(.+)/" => "/?page=devices&type=$1",
"^/interfaces/(.+)/" => "/?page=interfaces&type=$1",
"^/vrf/(.+)/(.+)/(.+)/" => "/?page=vrf&id=$1&opta=$2&optb=$3",
"^/vrf/(.+)/(.+)/" => "/?page=vrf&id=$1&opta=$2",
"^/vrf/(.+)/" => "/?page=vrf&id=$1",
"^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7&optf=$8&optg=$9",
"^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7&optf=$8",
"^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7",
"^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6",
"^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5",
"^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4",
"^/device/([0-9]+)/([a-z]+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3",
"^/device/([0-9]+)/([a-z]+)/" => "/?page=device&id=$1§ion=$2",
"^/device/([0-9]+)" => "/?page=device&id=$1",
"^/([a-z|0-9\-]+)/$" => "/?page=$1",
"^/([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6",
"^/([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3&optc=$4&optd=$5",
"^/([a-z|0-9]+)/(.+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3&optc=$4",
"^/([a-z|0-9]+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3",
"^/([a-z|0-9]+)/(.+)/$" => "/?page=$1&opta=$2"
)
}
Restart lighttpd and point your browser to the appropriate ip or hostname and enjoy your Observium installation served up by Lighttpd
/etc/init.d/lighttpd restart
Optional
The above example makes your /etc/lighttpd/lighttpd.conf file very cluttered. Lets move it out to another file and use an include to isolate and clean things up a bit
Place this in your /etc/lighttpd/lighttpd.conf instead of all the rewrite rules
$HTTP["host"] == "observium.example.com" {
include "observium.conf"
}
Now place your rewrite rules in and your server.document-root declarations in the file /etc/lighttpd/observium.conf
server.document-root = "/opt/observium/html" url.rewrite-once = ( "^/(.*)\.(png|css|jpg|gif|php)$" => "/$0", "^/cust/" => "/?page=cust", "^/bare/(.+)/" => "/index-bare.php?page=$1", "^/bare/(.+)/(.+)/" => "/index-bare.php?page=$1&opta=$2", "^/bare/(.+)/(.+)/(.+)/" => "/index-bare.php?page=$1&opta=$2&optb=$3", "^/mobile/([a-z|0-9]+)/(.+)/(.+)/" => "/mobile.php?page=$1&opta=$2&optb=$3", "^/mobile/([a-z|0-9]+)/(.+)/" => "/mobile.php?page=$1&opta=$2", "^/mobile/([a-z|0-9]+)/" => "/mobile.php?page=$1", "^/mobile/" => "/mobile.php", ## Rewrites for Devices "^/devices/location/(.+)/" => "/?page=devices&location=$1", "^/devices/alerted/" => "/?page=devices&status=alerted", "^/devices/(.+)/" => "/?page=devices&type=$1", "^/interfaces/(.+)/" => "/?page=interfaces&type=$1", "^/vrf/(.+)/(.+)/(.+)/" => "/?page=vrf&id=$1&opta=$2&optb=$3", "^/vrf/(.+)/(.+)/" => "/?page=vrf&id=$1&opta=$2", "^/vrf/(.+)/" => "/?page=vrf&id=$1", "^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7&optf=$8&optg=$9", "^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7&optf=$8", "^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7", "^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5&optd=$6", "^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5", "^/device/([0-9]+)/([a-z]+)/(.+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3&optb=$4", "^/device/([0-9]+)/([a-z]+)/(.+)/" => "/?page=device&id=$1§ion=$2&opta=$3", "^/device/([0-9]+)/([a-z]+)/" => "/?page=device&id=$1§ion=$2", "^/device/([0-9]+)" => "/?page=device&id=$1", "^/([a-z|0-9\-]+)/$" => "/?page=$1", "^/([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6", "^/([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3&optc=$4&optd=$5", "^/([a-z|0-9]+)/(.+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3&optc=$4", "^/([a-z|0-9]+)/(.+)/(.+)/$" => "/?page=$1&opta=$2&optb=$3", "^/([a-z|0-9]+)/(.+)/$" => "/?page=$1&opta=$2" )
Restart Lighttpd and have fun with Observium
/etc/init.d/lighttpd restart
--Bryan Smith (Bryanstein on irc.freenode.net) 07:44, 3 May 2011 (BST)