Install Adminer on Ubuntu 24.04: 4 Easy Steps, 3 Pitfalls
Adminer is a database manager in a single PHP file: you drop it on a web server with PHP, open it in a browser and log in to MySQL, MariaDB, PostgreSQL or SQLite. To install Adminer on Ubuntu you can follow the upstream way (download one file) or use the Ubuntu package. I repeated the steps of the 2023 version of this post on 22 November 2026 in an Ubuntu 24.04.5 container (Apache 2.4.58, PHP 8.3.6, MariaDB 10.11.14), then tried the package. Both work, with three pitfalls the old post did not mention: a missing PHP extension, an outdated package, and an access restriction that silently does nothing.
Contents
- Step 1: install Apache, PHP and the MySQL extension
- Step 2: install Adminer from adminer.org
- Step 3: the Apache virtual host from the old post
- Option B: install Adminer with apt (older version)
- Pitfall: restricting access that does nothing
- Reach a localhost-only Adminer through SSH
- Update or remove Adminer
- Checklist to install Adminer on Ubuntu safely
Step 1: install Apache, PHP and the MySQL extension
sudo apt update
sudo apt install apache2 php libapache2-mod-php php-mysql
Before you install Adminer itself, get the PHP side right. The old post installed only apache2 and php. That is not enough: in the lab, PHP had neither of the MySQL drivers Adminer needs until php-mysql was added:
$ php -m | grep -i -E "^(mysqli|pdo_mysql)$" || echo "no mysqli / pdo_mysql"
no mysqli / pdo_mysql
$ apt-get install -y php-mysql; service apache2 restart; php -m | grep -i -E "^(mysqli|pdo_mysql)$"
mysqli
pdo_mysql
The Adminer login page loads fine without the extension, so this mistake only shows up when you try to log in. For PostgreSQL, install php-pgsql instead or as well.
Step 2: install Adminer from adminer.org
$ wget -q https://www.adminer.org/latest.php -O adminer.php; ls -l adminer.php
-rw-r--r--. 1 root root 586294 Nov 20 17:09 adminer.php
$ grep -o "VERSION *= *.[0-9.]*" adminer.php | head -1
VERSION="6.3.1
$ sudo mkdir -p /var/www/html/adminer && sudo mv adminer.php /var/www/html/adminer/
$ sudo chown -R www-data:www-data /var/www/html/adminer
The "latest" link gave Adminer 6.3.1, one PHP file of about 573 KiB. The ownership change is not required for Adminer to run (it only reads its own file), but it does no harm.
Step 3: the Apache virtual host from the old post
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/adminer
ServerName localhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
$ sudo a2ensite adminer.conf; sudo apache2ctl configtest
Syntax OK
$ curl -s -o /dev/null -w "%{http_code}\n" http://localhost/adminer.php
200
$ curl -s http://localhost/adminer.php | grep -o "<title>[^<]*</title>"
<title>Login - Adminer</title>
It works, with two notes. This vhost uses ServerName localhost on port 80, so on a real server it competes with the default site; give it its own name or port. And the old post's a2enmod rewrite is not needed, because nothing in the setup uses rewrite rules.
Option B: install Adminer with apt (older version)
$ apt-cache policy adminer | head -3
adminer:
Installed: (none)
Candidate: 4.8.1-2
$ sudo apt install adminer; sudo a2enconf adminer; sudo systemctl reload apache2
$ curl -s -o /dev/null -w "%{http_code}\n" http://localhost/adminer/
200
$ cat /etc/apache2/conf-available/adminer.conf
Alias /adminer /etc/adminer
<Directory /etc/adminer>
Require all granted
DirectoryIndex conf.php
</Directory>
If you install Adminer this way, the package is convenient and gets security fixes through Ubuntu, but on 24.04 it is Adminer 4.8.1, two major versions behind the 6.3.1 file from adminer.org on the same day. It also publishes /adminer/ on every virtual host with Require all granted. Choose the upstream file if you want current features, the package if you prefer apt updates.
Pitfall: restricting access that does nothing
Whichever way you install Adminer, a database console must not be open to the internet. My first attempt was a separate file with Require ip 127.0.0.1 for /etc/adminer. It had no effect at all:
$ ls /etc/apache2/conf-enabled/ | grep adminer
adminer-local.conf
adminer.conf
from container IP: 200
Apache reads conf-enabled/ in alphabetical order, and adminer-local.conf sorts before adminer.conf, so the package's Require all granted came last and won. Renamed to zz-adminer-local.conf, the rule applied, and then blocked even me:
local: 403
curl -4 localhost: 200
curl -6 localhost: 403
localhost resolved to the IPv6 address ::1, which 127.0.0.1 does not match. The Apache mod_authz_host docs describe Require local as allowing 127.0.0.0/8, ::1, and connections where client and server address are the same, and with it both requests got 200. For access from your workstation, use Require ip with your admin network, a VPN, or an SSH tunnel to a localhost-only Adminer, and test the rule from outside the server.
Reach a localhost-only Adminer through SSH
The cleanest setup after you install Adminer on a server is to allow only local connections (Require local) and reach it through an SSH tunnel from your own machine:
ssh -L 8080:localhost:80 admin@your-server
# then open http://localhost:8080/adminer/ in your browser
The browser talks to your laptop's port 8080, SSH carries the request to the server, and Apache sees it coming from the server itself, so Require local lets it through. Nothing about Adminer is visible from the internet, and you do not need a separate password layer in Apache.
Update or remove Adminer
How you update depends on how you chose to install Adminer. With the upstream file, download latest.php again and replace the old file; there is nothing else to migrate, because Adminer keeps no data of its own. With the package, apt upgrade handles it, within the version Ubuntu ships. To remove it, delete the file (upstream) or run sudo a2disconf adminer and sudo apt remove adminer (package), then reload Apache. Check afterwards with curl that the URL really returns 404.
Checklist to install Adminer on Ubuntu safely
- Install
php-mysql(orphp-pgsql) with PHP. - Pick upstream (6.3.1) or the package (4.8.1) on purpose.
- Never leave it on a public vhost with
Require all granted; restrict by IP or VPN and test from another machine. - Log in with a dedicated database user with rights to one database, not with
root. - Remove it when you are done if you only needed it for a one-off task.
For changing the passwords of the database users you log in with, see MySQL change user password; for a broader web admin panel, Webmin. Downloads and the list of supported databases are on the Adminer website. I did not test logging in through Adminer itself in this lab; the checks above cover installing Adminer, its PHP requirement and access control.
Comments
Post a Comment