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:
- Install the vnstat package:
sudo yum install vnstat
- Install the Apache web server and PHP:
sudo yum install httpd php
- Start the Apache web server and enable it to start automatically at boot time:
sudo systemctl start httpd
sudo systemctl enable httpd
- Download the vnstat-php frontend:
wget https://github.com/MLBNET/vnstat-php-frontend/archive/master.zip
- Unzip the vnstat-php frontend:
unzip master.zip
- Move the vnstat-php frontend to the Apache document root:
sudo mv vnstat-php-frontend-master /var/www/html/vnstat-php
- Give the Apache user ownership of the vnstat-php frontend:
sudo chown -R apache:apache /var/www/html/vnstat-php
- 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
).
- 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";
- 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.