The vnstat frontend runs in PHP. We installed lighttpd but did not install php. Now we will install php and make the necessary changes in the lighttpd.conf to run it in cgi mode.
To run php in cgi mode, install mod_cgi for lighttpd
ipkg install lighttpd-mod-cgi
Now install php and gd for php
ipkg -d opt install php5 php5-cgi php5-mod-gd (dep. libgd, libjpeg, libpng)
the following files will be installed
/opt/etc/php.ini
/opt/usr/bin/php
/opt/usr/lib/php/gd.so
/opt/usr/lib/libgd.so.2.0.0
/opt/usr/lib/libgd.so.2
/opt/usr/lib/libjpeg.so.62.0.0
/opt/usr/lib/libjpeg.so.62
/opt/usr/lib/libpng.so.3.0.0
/opt/usr/lib/libpng12.so.0.0.0
/opt/usr/lib/libpng.so.3
/opt/usr/lib/libpng12.so.0
create symbolic link for php.ini file (by default cgi version of php looks for php.ini in /etc)
ln -s /opt/etc/php.ini /etc/php.ini
To enable mod_cgi in lighttpd, edit vi /etc/lighttpd.conf
uncomment server.modules, the corresponding closing brace and uncomment the line
"mod_cgi",
under #### CGI module add the line
cgi.assign = ( ".php" => "/opt/usr/bin/php" )
for running the php scripts when you hit a directory, index.php needs to be added to index-file.names. For that change the line
index-file.names = ( "index.html", "default.html", "index.htm", "default.htm" )
to
index-file.names = ( "index.html", "default.html", "index.htm", "default.htm", "index.php" )
To enable GD extension in PHP, edit /opt/etc/php.ini, uncomment the line
extension=gd.so
Because we have installed the GD module in a non-standard location, change the line
; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/lib/php"
to
; Directory in which the loadable extensions (modules) reside.
extension_dir = "/opt/usr/lib/php"
Restart lighttpd service
/etc/init.d/S80lighttpd stop
/etc/init.d/S80lighttpd start
download the vnstat PHP frontend from here, extract the files to the directory vnstat and copy that to your lighttpd document root
edit config.php under the vnstat PHP frontend directory and change the interfaces as shown below
$iface_list = array('eth0', 'eth1', 'eth2', 'br0');
$iface_title['eth0'] = 'Internal';
$iface_title['eth1'] = 'Internet';
$iface_title['eth2'] = 'eth2';
$iface_title['br0'] = 'Bridge';
also change the vnstat_bin variable to point to the vnstat executable for data collection by the script
$vnstat_bin = '/usr/bin/vnstat';
Now visit your web page at http:/192.168.1.1/vnstat/ for the GUI.
Monday, July 02, 2007
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment