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

To view vnstat graphs using a PHP web interface frontend on CentOS or RHEL, you can use the vnstat-php frontend. Here are the steps to install and configure vnstat-php:

  1. Install the vnstat package:
sudo yum install vnstat
  1. Install the Apache web server and PHP:
sudo yum install httpd php
  1. Start the Apache web server and enable it to start automatically at boot time:
sudo systemctl start httpd
sudo systemctl enable httpd
  1. Download the vnstat-php frontend:
wget https://github.com/MLBNET/vnstat-php-frontend/archive/master.zip
  1. Unzip the vnstat-php frontend:
unzip master.zip
  1. Move the vnstat-php frontend to the Apache document root:
sudo mv vnstat-php-frontend-master /var/www/html/vnstat-php
  1. Give the Apache user ownership of the vnstat-php frontend:
sudo chown -R apache:apache /var/www/html/vnstat-php
  1. Configure vnstat to collect data for the desired interfaces:
sudo vnstat --create -i <interface>

Replace <interface> with the name of the interface you want to collect data for (e.g., eth0).

  1. Configure the vnstat-php frontend:
sudo nano /var/www/html/vnstat-php/config.php

Edit the following line in the config.php file to match the location of the vnstat database on your system:

$vnstat_bin = "/usr/bin/vnstat";
  1. Restart the Apache web server:
sudo systemctl restart httpd

You should now be able to view the vnstat graphs by accessing the URL http://<your_server_name>/vnstat-php in a web browser. Replace <your_server_name> with the name of your server.

(https://www.ameriseed.net/)

Leave a Comment