VnStat PHP frontend – A Web Based Interface for Monitoring Network Bandwidth


VnStat PHP frontend is a graphical web interface for network utility called VnStat. VnStat PHP provides a simple graphical format where we can monitor IN and OUT traffic of network interfaces including statistics history (hourly, days, months or full summary).

This guide helps you to install VnStat PHP frontend on Linux systems.

System Requirements

Install and Configure VnStat

VnStat is a command line utility to monitor network bandwidth of interfaces and keeps the historical statistics on its database.


VnStat is not available in the main repository, so you need to enable EPEL repository for Redhat based derivatives.

# yum -y install vnstat

Once you have installed the VnStat, start it using the following command. (Ignore if it is already running).

# service vnstat start

Start VnStat on system boot using the following command.

# chkconfig vnstat on

Debian / Ubuntu

$ sudo apt-get install vnstat

Please wait at least ten minutes, and then run the following command. You should get similar output like below; this ensures that VnStat is working.

# vnstat

Database updated: Sun Apr 17 17:03:53 2016
   eth0 since 04/10/16
          rx:  1.12 GiB      tx:  110.13 MiB      total:  1.22 GiB
                     rx      |     tx      |    total    |   avg. rate
       Apr '16      1.12 GiB |  110.13 MiB |    1.22 GiB |    7.11 kbit/s
     estimated      2.00 GiB |     197 MiB |    2.19 GiB |
                     rx      |     tx      |    total    |   avg. rate
     yesterday     19.94 MiB |    6.73 MiB |   26.66 MiB |    2.53 kbit/s
         today      5.92 MiB |    5.26 MiB |   11.18 MiB |    1.49 kbit/s
     estimated         7 MiB |       7 MiB |      14 MiB |

Install Apache, PHP, and php-gd

Install the packages using “yum” on CentOS and “apt-get” on Debian,  start the Apache server after the installation.


# yum -y install httpd php php-gd wget
# chkconfig httpd on
# service httpd start

Configure the firewall to allow apache traffic (CentOS / RHEL).

### FirewallD ###

# firewall-cmd --permanent--add-service=http
# firewall-cmd --reload

### IPTables ###

# iptables -A INPUT -m tcp -p tcp --dport 80 -j ACCEPT
# service iptables restart

Ubuntu / Debian

### Ubuntu 15.10 / 14.04 and older/ Debian ###

$ sudo apt-get install apache2 php5 php5-gd wget
$ sudo service apache2 restart

### Adding PHP 5.6 PPA for Ubuntu 16.04 ###

$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install apache2 php5.6 php5.6-gd wget libapache2-mod-php5.6
$ sudo service apache2 restart

Download and Install VnStat PHP frontend

Use the wget command to download the latest VnStat PHP frontend from the official website.

# cd /tmp
# wget

Extract the downloaded package using “tar” command.

# tar -zxvf vnstat_php_frontend-1.5.1.tar.gz

Once the extraction is completed, move the directories to web server root directory.


# cp -a vnstat_php_frontend-1.5.1 /var/www/html/vnstat
# restorecon -Rv /var/www/html/vnstat/

Ubuntu / Debian

### Debain / Ubuntu 14.04 and later (Apache 2.4 and later) ###

$ sudo cp -a vnstat_php_frontend-1.5.1  /var/www/html/vnstat

### Ubuntu 13.10 and below (i.e older Apache 2.x) ###

$ sudo cp -a vnstat_php_frontend-1.5.1  /var/www/vnstat

Configure VnStat PHP frontend

Open the configuration file and modify the parameters shown below.

### CentOS / RHEL ###

# vi /var/www/html/vnstat/config.php

### Debain / Ubuntu 14.04 and later (Apache 2.4 and later) ###

$ sudo nano /var/www/html/vnstat/config.php

### Ubuntu 13.10 and below (i.e older Apache 2.x) ###

$ sudo nano /var/www/vnstat/config.php

Set the default language.

// edit these to reflect your particular situation
$locale = 'en_US.UTF-8';
$language = 'en';

Set which interface to be monitored.

// list of network interfaces monitored by vnStat
$iface_list = array('eth0', 'eth1');

You can name your network interfaces.

// optional names for interfaces
// if there's no name set for an interface then the interface identifier
// will be displayed instead
$iface_title['eth1'] = 'Internal';
$iface_title['eth0'] = 'External';

Access VnStat PHP frontend

Open up your browser and navigate it to any one of the following links. You would get an output like below; it shows you the usage summary (in hours, days and months) of your network interface.



VnStat PHP frontend - Web Based Interface for Monitoring Network
VnStat PHP frontend – Web-Based Interface for Monitoring Network
If you don’t get any data in the graph, consider disabling SELinux on CentOS 7 / CentOS 6.


SqweekOfficial Home Page

You might also like