- Joined
- Feb 19, 2019
- Messages
- 13
I know some of you already have something up to track your bandwidth usage but this is for those who dont.
I am using Ubuntu 20.04.
1) Install all dependencies
2) Start vnstat
3) Configure nginx to use PHP
4) Install Web Interface
5) Optional: TImezone on web interface.
You will need to edit the config file and change the timezone.
Config is located in /var/www/html/includes/config.php
Change: date_default_timezone_set('Europe/London');
To: date_default_timezone_set('YOUR_TIME_YOU_WANT');
Full list here: https://www.php.net/manual/en/timezones.php
6) Optional: If your interface is not showing up
7) If all works, go to your http://YOURIP and you should see the dashboard
I am using Ubuntu 20.04.
1) Install all dependencies
Code:
apt install nginx php7.4 php7.4-fpm php7.4-gd vnstat composer git
2) Start vnstat
Code:
systemctl start vnstat.service
3) Configure nginx to use PHP
Find
Change to
Find
Change to
Now run - nginx -t
Should get
Now run - systemctl restart nginx
Code:
index index.xhtml index.html index.htm index.nginx-debian.html;
Code:
index index.php index.xhtml index.html index.htm index.nginx-debian.html;
Find
Code:
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
Code:
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
Now run - nginx -t
Should get
Code:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Now run - systemctl restart nginx
4) Install Web Interface
Code:
rm /var/www/html/*.html
mkdir /var/www/vnstat && cd "$_"
git clone https://github.com/ochbob/vnstat-dashboard.git .
cp -rp app/* ../html
cd ..
chmod u+wx -R html
cd /var/www/html
composer install
Ignore the warning about using as root
5) Optional: TImezone on web interface.
You will need to edit the config file and change the timezone.
Config is located in /var/www/html/includes/config.php
Change: date_default_timezone_set('Europe/London');
To: date_default_timezone_set('YOUR_TIME_YOU_WANT');
Full list here: https://www.php.net/manual/en/timezones.php
6) Optional: If your interface is not showing up
You will need to manually set it.
In my case here, ens18 is my main ethernet port. The way you can tell, is it has your main IP assigned.
Now edit the config file in /var/www/html/includes/config.php
Change: $use_predefined_interfaces = false;
To: $use_predefined_interfaces = true;
Change: $interface_list = ["eth0", "eth1"];
To: $interface_list = ["ens18"];
Change:
$interface_name['eth0'] = "Internal #1";
$interface_name['eth1'] = "Internal #2";
To:
$interface_name['ens18'] = "Internal";
//$interface_name['eth1'] = "Internal #2";
Code:
ifconfig
ens18: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet xxx.xxx.xxx.xxx netmask 255.255.255.255 broadcast 0.0.0.0
inet6 xxxxxxxx prefixlen 64 scopeid 0x20<link>
ether xxxxxxxx txqueuelen 1000 (Ethernet)
RX packets 912885699 bytes 186284231955 (186.2 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1878307654 bytes 3074553185390 (3.0 TB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 19176 bytes 2090236 (2.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 19176 bytes 2090236 (2.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
In my case here, ens18 is my main ethernet port. The way you can tell, is it has your main IP assigned.
Now edit the config file in /var/www/html/includes/config.php
Change: $use_predefined_interfaces = false;
To: $use_predefined_interfaces = true;
Change: $interface_list = ["eth0", "eth1"];
To: $interface_list = ["ens18"];
Change:
$interface_name['eth0'] = "Internal #1";
$interface_name['eth1'] = "Internal #2";
To:
$interface_name['ens18'] = "Internal";
//$interface_name['eth1'] = "Internal #2";
7) If all works, go to your http://YOURIP and you should see the dashboard
