Adminer is a great tool for managing many different kinds of databases. It is easy to set up and easy to use. In this tutorial, I'll be showing you how to set it up locally on your computer.
This tutorial is made specifically for Ubuntu and other Debian-based systems, however, with few adjustments, it can be made to work on other Linux distributions. Ok, let's get started.
sudo mkdir -p /usr/local/share/adminer
Grab the latest version of Adminer and save it to the directory we just created:
sudo wget -O /usr/local/share/adminer/adminer.php https://www.adminer.org/latest.php
Create an index.php
file with an include statement pointing to adminer.php
. We will reference
index.php
in our nginx configuration file.
<?php
include "./adminer.php";
If you haven't already, install nginx. Create an nginx config file, adminer.test
, in /etc/nginx/sites-available/
:
server {
listen 80;
server_name adminer.test;
root /usr/local/share/adminer/;
# If you want to use a .htpass file, uncomment the three following lines.
#auth_basic "Admin-Area! Password needed!";
#auth_basic_user_file /usr/local/share/adminer/.htpass;
#access_log /var/log/nginx/adminer.test-access.log;
error_log /var/log/nginx/adminer.test-error.log;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
}
}
Enable the config:
ln -s /etc/nginx/sites-available/adminer.test /etc/nginx/sites-enabled/adminer.test
Restart nginx to register the changes.
sudo systemctl restart nginx.service
To access adminer from http://adminer.test, add adminer.test
at the end of the line
which binds 'localhost' to the loopback address in the /etc/hosts
file:
127.0.0.1 localhost adminer.test
Now open a browser and type the http://adminer.test. You should be see the Adminer login page.
To access Adminer via http://localhost/adminer, create a symlink of the adminer directory to the web root:
ln -s /usr/local/share/adminer /var/www/html/
NOTE
Ensure that the extensions for all the databases you want to use are enabled in yourphp.ini
configuration file. Eg.extension=pdo_mysql extension=mysqli
To keep adminer up-to-date, create a script named update-adminer
:
echo 'wget -O adminer.php http://www.adminer.org/latest.php' > update-adminer
chmod +x update-adminer
sudo mv update-adminer /usr/local/share/adminer/
Run the script in the Adminer root directory whenever you want to retrieve the latest version of Adminer.
sudo /usr/local/share/adminer/update-adminer
That's it.
As a bonus, If you use Laravel and the tool
Valet, setting up Adminer is as simple as creating a directory,
adminer
, with theadminer.php
, index.php
and update-adminer
files. Valet will handle
serving the application at http://adminer.test. Secure domains are also supported and handled
automatically (eg. https://adminer.test).