In this tutorial, we'll learn how to install and use Adminer on Ubuntu 24.04 with Nginx.
Introduction
Adminer is a powerful, lightweight, and easy-to-use database management tool that serves as an excellent alternative to phpMyAdmin. Unlike phpMyAdmin, which requires multiple files and dependencies, Adminer is just a single PHP file that you can easily deploy on any web server. It supports multiple database management systems, including MySQL, PostgreSQL, SQLite, and MariaDB.
If you are looking for a simple, fast, and secure way to manage your databases without the overhead of phpMyAdmin, Adminer is a great choice.
Prerequisites
- A Ubuntu 24.04 installed dedicated server or KVM VPS.
- A root user or normal user with administrative privileges.
- A domain name point A record to server's IP
How to Install and Use Adminer on Ubuntu
Step 1: Install Nginx (If Not Installed)
Execute following command to install Nginx:
sudo apt install nginx -y
Enable and Start Nginx
sudo systemctl enable nginx
sudo systemctl start nginx
To check if Nginx is running:
sudo systemctl status nginx
You should see "active (running)".
Step 2: Configure firewall
We need allow HTTP and HTTPS port in the firewall.
ufw allow 80/tcp
ufw allow 443/tcp
Step 3: Install PHP and Required Extensions
Since Adminer is a PHP-based application, we need to install PHP along with some necessary extensions. Run the following command:
sudo apt install php-fpm php-cli php-mysql -y
Once installed, confirm that PHP is working:
php -v
You should see output showing the installed PHP version.
Step 4: Install and Configure Adminer
Ubuntu provides an Adminer package in its official repositories, making installation very simple:
sudo apt install adminer -y
Step 5: Configure Nginx for Adminer
Now, let’s create an Nginx configuration file for Adminer.
Open a new file in Nginx’s sites-available directory:
sudo nano /etc/nginx/sites-available/adminer
Add the following Nginx configuration:
server {
listen 80;
server_name adminer.yourdomain.com;
root /usr/share/adminer/adminer;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location /adminer/ {
root /usr/share/adminer;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|png|gif|css|js|ico|svg|woff|woff2|ttf|otf|eot|mp4|avi|mov)$ {
expires max;
log_not_found off;
access_log off;
root /usr/share/adminer;
}
error_log /var/log/nginx/adminer_error.log;
access_log /var/log/nginx/adminer_access.log;
}
📌 Make sure to replace adminer.yourdomain.com with your actual domain.
Enable the Nginx Site and Restart Nginx
Create a symbolic link to enable the new configuration:
sudo ln -s /etc/nginx/sites-available/adminer /etc/nginx/sites-enabled/
Test the Nginx configuration for errors:
sudo nginx -t
If there are no errors, you’ll see: "syntax is OK"
Restart Nginx to apply changes:
sudo systemctl restart nginx
Step 6: Secure Adminer with an SSL Certificate (HTTPS)
Install Certbot and Let’s Encrypt SSL
Let’s Encrypt provides free SSL certificates that automatically renew.
Install Certbot and the Nginx plugin:
sudo apt install certbot python3-certbot-nginx -y
Generate an SSL certificate for your domain:
sudo certbot --nginx -d adminer.yourdomain.com
After installation, Certbot will automatically configure your Nginx file to use HTTPS.
Step 7: Log in to Adminer and Manage Your Databases
Open your web browser and go to:
https://adminer.yourdomain.com
You'll see a login screen with the following fields:
- System: Select MySQL or MariaDB.
- Server: Use localhost (or your database server IP).
- Username: root (or any other database user).
- Password: Your MySQL user password.
- Database: Leave blank to see a list of databases.
Click Login.
Once inside, you can:
- Create databases
- Manage tables
- Run SQL queries
- Import/export data
Adminer provides a simple and clean interface to handle all database operations.
Step 8: Secure Adminer (Optional but Recommended)
Since Adminer is a database management tool, you should restrict access only to authorized users.
Option 1: Restrict Access by IP Address
Edit the Nginx configuration:
sudo nano /etc/nginx/sites-available/adminer
Add this inside the location /
block:
allow YOUR_IP_ADDRESS;
deny all;
Replace YOUR_IP_ADDRESS
with your actual public IP.
Restart Nginx:
sudo systemctl restart nginx
Option 2: Protect with a Password
Install Apache’s htpasswd tool:
sudo apt install apache2-utils -y
Create a password file:
sudo htpasswd -c /etc/nginx/.htpasswd adminer_user
Enter a strong password when prompted.
Edit the Nginx configuration:
sudo nano /etc/nginx/sites-available/adminer
Add this inside the location / block:
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.htpasswd;
Restart Nginx:
sudo systemctl restart nginx
Now, when you access Adminer, it will prompt you for a username and password before you can log in.
Conclusion
In this tutorial, we've learnt how to install and use Adminer on Ubuntu 24.04 with Nginx.
🎉 Congratulations! You have successfully:
✅ Set up Adminer with a custom domain name (adminer.yourdomain.com)
✅ Replaced Apache with Nginx for better performance
✅ Installed a free SSL certificate for secure HTTPS access
✅ Implemented security measures like IP restriction or password protection
Now you have a fully secure and easily accessible database management tool running on your domain. 🚀
If you need any further customizations, let me know! 😊