CentOS / RHEL: View Vnstat Graphs Using PHP Web Interface Frontend

by on November 20, 2012 · 6 comments· LAST UPDATED November 20, 2012

in ,

How do Install view vnstat - a network console output using my web-browser? How do I install vnstat php frontend on CentOS / RHEL / Fedora Linux based system?

Tutorial details
DifficultyIntermediate (rss)
Root privilegesYes
RequirementsApache 2.x+ / PHP 5.x+
CentOS/ SL / Fedora/ RHEL
Estimated completion timeN/A

You can use a PHP fronted for vnStat called "vnStat php frontend". This script was created as vnstat is console mode only and the author wanted to make a nice report of the data collected by vnStat. You need to install the following software(s) on your server:

[a] Apache

[b] PHP 5

[c] php-gd extension

You can install all of the above softwares using the yum command:
# yum install httpd php php-gd
Configure httpd service as per your requirements:
# vi /etc/httpd/conf/httpd.conf
Turn on the httpd service:
# chkconfig httpd on
# service httpd start
# netstat -tulpn | grep :80

Download vnStat php frontend

Visit this url and grab the latest version using the wget command:
$ cd /tmp
$ wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz

Untar or extract the tarball (tar file) called vnstat_php_frontend-1.5.1.tar.gz, type:
$ tar xvf vnstat_php_frontend-1.5.1.tar.gz

Install vnStat php frontend

You need to install this frontend at the following location:
Make a directory called /var/www/html/vnstat/ using mkdir command:
# mkdir -p /var/www/html/vnstat/
Copy files from /tmp/vnstat_php_frontend-1.5.1 to /var/www/html/vnstat using cp command, enter:
# cp -av /tmp/vnstat_php_frontend-1.5.1/* /var/www/html/vnstat
If you are using SELinux, restore file(s) default SELinux security contexts using restorecon command:
# restorecon -Rv /var/www/html/vnstat/

Configure vnStat php frontend

You need to edit /var/www/html/vnstat/config.php, enter:
# vi /var/www/html/vnstat/config.php
You need to edit this file to reflect your particular situation. First, set language to en:

$language = 'en';

I am monitoring eth0 and eth1. So list of network interfaces monitored by vnStat should be set using the following:

$iface_list = array('eth0', 'eth1');

You can set names for interfaces:

$iface_title['eth0'] = 'Internal';
$iface_title['eth1'] = 'External';

Save and close the file.

How do I view graphs?

Fire a web browser and type the url:


Sample outputs:

Fig.01: vnstat network summary graph

Fig.01: vnstat network summary graph

Fig.02: vnstart daily traffic graphs

Fig.02: vnstart daily traffic graphs

Fig.03: vnstat monthly network traffic log

Fig.03: vnstat monthly network traffic log

Check out related media

This tutorial is also available in a video format:

(Video.01: Demo: Setup and use vnStat )

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?
This entry is 2 of 2 in the vnStat Monitor and Log Network Traffic Tutorial series. Keep reading the rest of the series:
  1. Install vnStat Network Traffic Monitor To Keep a Log Of Daily Traffic
  2. View Vnstat Graphs Using PHP Web Interface Frontend

{ 6 comments… read them below or add one }

1 Jalal Hajigholamali November 21, 2012 at 4:53 am


very nice article…


2 Andres November 24, 2012 at 1:44 pm

Nice tool for customers meetings :-)


3 Shashank Wagh December 1, 2012 at 11:56 am

This blog has great essence of technical knowledge. This is awesome. Thanx for penning down your experience. Thanx once again. I’ve been reading many web hosting blogs, web development blogs, but I believe this one stands tall.


4 galihrezah July 15, 2013 at 4:49 am

i will try on my vps.. and i will share
thanks for inspiration


5 dkraft January 30, 2014 at 1:50 pm

This works flawlessly. Thank you for your excellence.


6 foobrew May 27, 2014 at 11:56 pm

Might want to make sure you have your date.timezone set correctly in /etc/php.ini


For example,

date.timezone = “America/Los_Angeles”


Leave a Comment

Tagged as: , , , , ,

Previous Faq:

Next Faq: