How to install Adminer on Ubuntu 20.04 LTS

How do I install Adminer on Ubuntu 20.04 LTS for database management over the web?

Adminer (formerly known as phpMinAdmin) is an open-source and free web-based database management tool. It is written in PHP. As compared to phpMyAdmin, it is a lightweight application with strong security and user experience in mind. This tutorial describes how to install Adminer on Ubuntu 20.04 LTS Linux server for MySQL or MariaDB.
Tutorial requirements
Operating system/appUbuntu Linux and Apache 2 with PHP
Root privileges required Yes
Difficulty Easy (rss)
Estimated completion time 10m
Table of contents

ADVERTISEMENTS

Procedure to install Adminer on Ubuntu 20.04 Linux server

  1. Update your Ubuntu server running sudo apt update && sudo apt upgrade
  2. Make sure Apache server installed and configured on Ubuntu
  3. Install Adminer by typing the sudo apt install adminer command.
  4. Enable configuration, run: sudo a2enconf adminer
  5. Log in and start accessing database using https://your-domain/adminer/ URL.

Obviously, you need Apache or any other web server installed. Here is how to install Apache 2 on Ubuntu 20.04 LTS. Now that Apache web server installed and running let us get our hands dirty by installing Adminer.

Installing Adminer

First update the system using the apt command/apt-get command and then install Adminer software:
sudo apt update
sudo apt upgrade
sudo apt install adminer

How to install Adminer on Ubuntu 20.04 Linux using apt command
Please note that apart from Apache PHP required to run Adminer. Hence, apt installed PHP and automatically configured it too. For other web servers, you need to perform manual configurations. Use the cat command to verify that PHP 7.4 module is enabled:
a2query -m php7.4
php7.4 (enabled by maintainer script)
cat /etc/apache2/mods-enabled/php7.4.{load,conf}

Config files:

# Conflicts: php5
# Depends: mpm_prefork
LoadModule php7_module /usr/lib/apache2/modules/libphp7.4.so
<FilesMatch ".+\.ph(ar|p|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(ar|p|ps|tml)$">
    Require all denied
</FilesMatch>
 
# Running PHP scripts in user directories is disabled by default
# 
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_flag engine Off
    </Directory>
</IfModule>

Configuring Adminer

To activate adminer app run any one of the following a2enconf command sudo a2enconf adminer.conf
## OR ##
sudo a2enconf adminer

Outputs:

Enabling conf adminer.
To activate the new configuration, you need to run:
  systemctl reload apache2

Now all you have to do is restart or reload the Apache 2 server, enter:
sudo systemctl reload apache2
The default config file is located at /etc/apache2/conf-enabled/adminer.conf and viewed using the cat command:
sudo cat /etc/apache2/conf-enabled/adminer.conf

# Adminer on Ubuntu 20.04 #
Alias /adminer /etc/adminer
 
<Directory /etc/adminer>
	Require all granted
	DirectoryIndex conf.php
</Directory>

Test the installation

You can access the Adminer app using the following URL format:
https://your-server-name/adminer/
https://your-server-ip/adminer/
https://server1.cyberciti.biz/adminer/

Adminer running on Ubuntu 20.04
Now all you have to do is provide database type (MySQl, PGSQL), server IP/hostname, database username/password, and database name to login and manage the database:
adminer mysql login

A note about firewall configuration

Say Apache/adminer is running on the host having IP 10.105.28.9 address and database server is at 172.16.3.1:3306, then allow access using the ufw (type command on mysql/mariadb server):
sudo ufw allow from 10.105.28.9 to 172.16.3.1 port 3306 proto tcp comment 'allow mysql access for Adminer/Apache IP'
See UFW on Ubuntu 20.04 LTW page for detailed information. Next, you need to make sure database permissions and password are correct, otherwise admire would not be able to connect to your database server. In other words, create an admin user for admirer as follows (again type these on on your mysql/mariadb server). The syntax is:

CREATE USER 'admin'@'YOUR-ADMINER-SERVER-IP' IDENTIFIED BY 'YOUR-PASSWORD';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'YOUR-ADMINER-SERVER-IP' WITH GRANT OPTION;
 
## IF ADMINER/Apache server IP IS 10.105.28.9, THEN CREATE log IN USER named vivek ##
CREATE USER 'vivek'@'10.105.28.9' IDENTIFIED BY 'Super_Secret_PassWord_Here';
GRANT ALL PRIVILEGES ON *.* TO 'vivek'@'10.105.28.9' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Log in session

Installed Adminer on Ubuntu 20.04 and Logged in using vivek user

Adminer in action

Conclusion

In this tutorial, you learned how to install Adminer on Ubuntu 20.04 LTS Linux server. I strongly suggest that you run Adminer over HTTPS-based session (see “How To Secure Apache with mod_md Let’s Encrypt on Ubuntu 20.04 LTS“) and password protect your domain or /adminer/ URL for security reasons. See Adminer website here for more info.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • jj hurley Sep 16, 2020 @ 16:53

    Hi
    FYI: I see no reference to either MySQL or MariaDB being installed. Otherwise, thank you.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.