STEP1
# install webserver
apt install apache2
apt install php php-curl php-mbstring php-xml php-gd php-dev php-pear php-ssh2 libmcrypt-dev php-zip php-xml php-xsl php-mysql libapache2-mod-php
apt install mariadb-server mariadb-client phpmyadmin
pecl install mcrypt
mysql_secure_installation
mysql -u root -p mysql
update mysql.user set plugin='' where user='root';
flush privileges;
exit;
STEP2
# edit config php.ini add
extension=mcrypt.so
/etc/php/7.4/apache2/php.ini
/etc/php/7.4/cli/php.ini
STEP3
# Install FreeRadius
apt install freeradius freeradius-utils freeradius-mysql
cd /etc/freeradius/3.0/mods-enabled
ln -s ../mods-available/sql sql
nano /etc/freeradius/3.0/sites-available/default
# "Uncomment -sql and #sql"
#-- edit --
authorize {
#expiration
#logintime
quotalimit
dailycounter
accessperiod
monthlycounter
noresetcounter
}
nano /etc/freeradius/3.0/sites-available/inner-tunnel
# "Uncomment -sql and #sql"
nano /etc/freeradius/3.0/mods-available/sql
#------------- Edit --------------
driver = "rlm_sql_mysql"
dialect = "mysql"
server = "localhost"
port = 3306
login = "radius"
password = "radius1234"
radius_db = "radius"
read_clients = yes
client_table = "nas"
chgrp -h freerad /etc/freeradius/3.0/mods-enabled/sql
sudo nano /etc/freeradius/3.0/radiusd.conf
#-- Add --
$INCLUDE mods-enabled/
$INCLUDE mods-available/sqlcounter
STEP4
# config sqlcounter
nano /etc/freeradius/3.0/mods-available/sqlcounter
#tambahkan kode ini dibagian paling bawah
sqlcounter accessperiod {sql_module_instance = sqldialect = ${modules.sql.dialect}counter_name = Max-Access-Period-Timecheck_name = Access-Periodkey = User-Namereset = never$INCLUDE ${modconfdir}/sql/counter/${dialect}/${.:instance}.conf}sqlcounter quotalimit {sql_module_instance = sqldialect = ${modules.sql.dialect}counter_name = Max-Volumecheck_name = Max-Datareply_name = Mikrotik-Total-Limitkey = User-Namereset = never$INCLUDE ${modconfdir}/sql/counter/${dialect}/${.:instance}.conf}
STEP5
#bikin file sqlcounter (accessperiod.conf dan quotalimit.conf)
#-- Add Query --
sudo nano /etc/freeradius/3.0/mods-config/sql/counter/mysql/accessperiod.conf
query = "\SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(AcctStartTime) \FROM radacct \WHERE UserName='%{${key}}' \ORDER BY AcctStartTime LIMIT 1"
#-- Add Code --
sudo nano /etc/freeradius/3.0/mods-config/sql/counter/mysql/quotalimit.conf
query = "\SELECT (SUM(acctinputoctets) + SUM(acctoutputoctets)) \FROM radacct \WHERE UserName='%{${key}}'"
# atau dengan mengcopy file sqlcounter setelah install mangospot
cp /var/www/html/MangoSpot/SQL/sqlcounter-mysql/accessperiod.conf /etc/freeradius/3.0/mods-config/sql/counter/mysql/accessperiod.conf
cp /var/www/html/MangoSpot/SQL/sqlcounter-mysql/quotalimit.conf /etc/freeradius/3.0/mods-config/sql/counter/mysql/quotalimit.conf
STEP6
#install mangospot
apt update
apt install git
cd /var/www/html
git clone https://github.com/mangospot-net/MangoSpot
#-- OR --
wget https://github.com/mangospot-net/MangoSpot/archive/refs/heads/master.zip
unzip master.zip
STEP7
#-- Import database --
# bisa dilihat di folder SQL
#-- Edit file config.php --
nano /var/www/html/MangoSpot/include/config.php
/etc/init.d/freeradius restart
STEP8
#-- Enable htaccess on apache --
#masalah tampilan mangospot tidak normal butuh setting ini
a2enmod rewrite
nano /etc/apache2/sites-available/000-default.conf
#tambahkan setelah DocumentRoot /var/www/html
<Directory />
Options FollowSymlinks
AllowOverride All
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymlinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
/etc/init.d/apache2 restart
pkill radius
freeradius -X
systemctl start freeradius
systemctl enable freeradius
systemctl status freeradius
sudo /etc/init.d/freeradius restart
SELESAI