FreeRADIUS is a high performance RADIUS Server that accepts a large number of networking devices as RADIUS Client including MikroTik Router. MySQL is one of the best user sources for freeRADIUS server. In my previous article, I discussed how to install freeRADIUS server on CentOS 7 and how to integrate MySQL module with freeRADIUS server. I also discussed how to create user group and profile in MySQL database server and authenticate MikroTik PPPoE client with MySQL database user. I used MySQL Command Line Interface (CLI) to insert user information in database server. But most of the people like Graphical User Interface (GUI) rather than Command Line Interface (CLI). A lot of Graphical Software (such as MySQL Workbench, DBTools Manager, phpMyAdmin and so on) can be found to manage MySQL (MariaDB) database graphically. Among these, in this article I will show how to install and configure phpMyAdmin to manage freeRADIUS MySQL database because phpMyAdmin is a free MySQL (MariaDB) management tool over Web Interface.
phpMyAdmin Installation and Configuration on CentOS 7
phpMyAdmin is a free and open source MySQL and MariaDB database administration tool that is written in PHP and can manage over Web Interface. So, to get phpMyAdmin we should have PHP installed and Web Server (http service) running. As our freeRADIUS Server and MariaDB Database Server are running on CentOS 7, we will only install and configure Web Server, PHP and phpMyAdmin and then login to our MariaDB Database Server with phpMyAdmin Web Interface and manage our freeRADIUS users. The following steps will show how to install and configure Web Server, PHP and phpMyAdmin.
Step 1: Apache Web Server Installation and Configuration
Apache is an open-source and multi-platform web server application. Apache has a full range of web server features including CGI, SSL and virtual domains. In CentOS Linux, the Apache Server package is httpd (HTTP Daemon). So, we will now install httpd package that will turn on Apache HTTP Server in CentOS Linux.To install Apache HTTP Server, issue the following command from your CentOS 7 terminal.
The httpd package will be installed within a few second. After installing apache httpd package, we have to start the Apache service with the following command.
Apache service is now active and running and waiting for the incoming web (http) requests. The daemon will now answer any incoming http request.
But if your server gets rebooted in any case, the httpd daemon will not be stated automatically. So, run the following commend to start apache service automatically if any system restart is occurred.
You can check your web server status at any time with the following command.
HTTP Service runs on TCP 80 port. So, we have to allow port 80 or http service in CentOS firewall.
So, issue the following firewall commands to allow http service through your firewall.
[root@webserver ~]# firewall-cmd –zone=public –add-service=http –permanent
[root@webserver ~]# firewall-cmd –reload
Now open your web browser and navigate to http://localhost/ from your server or http://server-ip-address/ from any network workstation. If everything is OK, you will get the apache test page like the below image.
Step 2: PHP Installation
After installing http service, we have to install PHP because phpMyAdmin is written in PHP (hypertext preprocessor) server side scripting language. To install PHP in CentOS Linux, issue the following command in your terminal.
Now install some common PHP modules that are sometimes required with the following command.
To test PHP installation, create a simple php file (testphp.php) in Apache document root folder (by default /var/www/html) with the following command.
And add the following php code in this file.
phpinfo();
?>
Now restart httpd service with the following command.
Type http://ip-address/testphp.php in your browser to open phptest.php file. If everything is OK, you will fing all the details about PHP such as PHP version, build date and commands etc like the below image.
Step 3: phpMyAdmin Installation
We will now install phpMyAdmin in our CentOS Linux. By default phpMyAdmin is not found in CentOS official repositories. So, we have to install it using EPEL repository. To install EPEL repository, first download EPEL package with the wget command and then install it in your CentOS system according to the following command.
[root@freeradius ~]# yum install wget -y
[root@freeradius ~]# wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
[root@freeradius ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@freeradius ~]# rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
EPEL repository is now ready. So, issue the following command to install phpMyAdmin.
phpMyAdmin is now installed in our CentOS Linux. But before getting phpMyAdmin web interface, we have to do a simple configuration.
phpMyAdmin Configuration
To get phpMyAdmin web interface, we have to edit the phpmyadmin.conf file. So, open phpmyadmin.conf file with a text editor.
Now find and comment the whole <Directory> section as shown below.
[…]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
#<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# Require local
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>
[…]
And add the following lines just below the commented section.
Options none
AllowOverride Limit
Require all granted
</Directory>
Restart the httpd service with the following command.
Now phpMyAdmin can be found by navigating http://server-ip-address/phpmyadmin/ from your web browser.
Now login to phpMyAdmin with your root user credential and you will find all the databases in your MySQL or MariaDB database server including our desired radius database. Click on the radius database and you will find the tables created in radius database in the right panel. Click on any table and you will find inserted data in your table.
You can export your database or import a backup database with the Export and Import tab respectively as well as you can do any database operation from here graphically.
We will now insert a new user (jack) who will get 2M_Profile. So, his two entries in radcheck table will be…
username | attribute | op | value |
jack | Cleartext-Password | := | passme |
jack | User-Profile | := | 2M_Profile |
By default phpMyAdmin provides two rows at a time to insert. But we want to insert one row at a time. So, we need to change the default settings. The following steps will show how to change default edit mode in phpMyAdmin.
- Click on Settings tab from phpMyAdmin home page.
- Under Settings tab, click on Main panel button and then click on Edit mode tab.
- From Edit mode tab, change Number of inserted rows from 2 to 1.
- Now click Apply button.
Default insert row has been changed. Now click on radius database and click on radcheck table and then click on Insert tab. Put username (jack), attribute (Cleartext-Password), op (:=) and value (passme) for jack user and click Go button.
You will find 1 row inserted message. Click on Browse button and you will find jack is inserted here. Now click Insert tab again to insert jack’s profile. Put username (jack), attribute (User-Profile), op (:=) and value (2M_Profile) for jack user and click Go button.
Clicking browse button, you will also find that the profile of jack user has been inserted there.
New user creation with user profile has been completed with the phpMyAdmin database management tool. You can create as many users as you need following this step. Now we will check this user with the radtest program. So, login to the radius server with root user credential and issue the following command.
[root@freeradius ~]# radtest jack passme 127.0.0.1 100 testing123 1
Sent Access-Request Id 73 from 0.0.0.0:36674 to 127.0.0.1:1812 length 80
User-Name = “jack”
User-Password = “passme”
NAS-IP-Address = 192.168.40.10
NAS-Port = 100
Message-Authenticator = 0x00
Framed-Protocol = PPP
Cleartext-Password = “passme”
Received Access-Accept Id 73 from 127.0.0.1:1812 to 0.0.0.0:0 length 136
Framed-Protocol = PPP
Framed-Compression = Van-Jacobson-TCP-IP
Framed-Pool = “2M_pool”
Mikrotik-Rate-Limit = “2M/2M 4M/4M 2M/2M 40/40”
Reply-Message = “Hello jack! The database time is now 01:56:07. Your usage is 0”
[root@freeradius ~]#
If everything is OK, you will find the above output that means jack is a freeRADIUS user who is able to use PPP service and his bandwidth limit is 2mbps. So, you can use this user to authenticate as a MikroTik PPPoE client that I described in the previous article.
If you face any confusion to follow above steps properly, follow the below video about phpMyAdmin installation and configuration for freeRADIUS MySQL management. I hope it will reduce your any confusion.
How to install and configure phpMyAdmin database management tool to manage freeRADIUS MySQL database has been discussed in this article. I hope you will be able to install phpMyAdmin to manage your freeRADIUS MySQL. However, if you face any confusion, discuss in comment or contact with me from Contact page. I will try my best to stay with you. In near future, we will learn freeRADIUS unlang to control freeRADIUS process as well as how to control freeRADIUS graphically with PHP language. So, keep tune with SystemZone.