Adminer is a powerful and lightweight database management tool that allows you to easily manage databases like MySQL, PostgreSQL, SQLite, and others. It is a single PHP file, which makes it a perfect solution for those who prefer a simple, fast, and secure way to manage their databases from a web interface.
In this guide, we will walk you through the steps to install and set up Adminer on a VPS to manage your databases efficiently.
Prerequisites
Before you begin the installation, ensure the following:
- A VPS running Ubuntu 20.04 or later (This guide assumes Ubuntu; you can adapt the instructions for other distributions such as CentOS or Debian).
- Root or sudo access to your VPS.
- A web server (Apache or Nginx).
- PHP installed on your server (PHP 7.1 or later recommended).
- A working MySQL, MariaDB, PostgreSQL, or SQLite database (or any other supported database).
Step 1: Update Your VPS
To ensure your system packages are up to date, run the following commands:
- Update system packages:
Step 2: Install Apache, PHP, and Required Extensions
Adminer requires a web server (Apache) and PHP to run. Follow these steps to install them.
Install Apache
-
Install Apache Web Server:
-
Enable Apache to start on boot:
-
Verify Apache Installation: Open your browser and navigate to your server's IP address. You should see the default Apache page. Alternatively, check Apache's status:
Install PHP
Adminer requires PHP to function properly. Install PHP and the necessary extensions:
-
Install PHP and extensions:
-
Verify PHP installation:
Step 3: Download and Install Adminer
-
Navigate to the Web Directory: The default web directory for Apache is
/var/www/html
. Navigate to it: -
Download Adminer: Adminer is a single PHP file, and you can download it directly using
wget
orcurl
. Run the following command to download the latest version of Adminer: -
Set Correct Permissions: Ensure that the file has the correct permissions for the Apache server to serve it:
Step 4: Configure Apache for Adminer
Since Adminer is a single PHP file, you don't need to configure any complex settings for it. However, you may want to set up a custom domain or alias to access it more easily.
-
Create an Apache Configuration File (Optional): If you want to use a custom alias (e.g.,
adminer.yourdomain.com
), you can create an Apache virtual host configuration.Create a new file in the Apache
sites-available
directory:Add the following content:
Note: Replace
adminer.yourdomain.com
with your actual domain name. If you don’t have a domain, you can access Adminer using the server's IP address (e.g.,http://your_server_ip/adminer.php
). -
Enable the New Site Configuration: Enable your new site and restart Apache:
-
Enable mod_rewrite (Optional): If you want to use pretty URLs or rewrite URLs, enable Apache’s
mod_rewrite
:
Step 5: Access Adminer
-
Access Adminer: Open your web browser and go to the following URL:
- If you're using a domain:
http://adminer.yourdomain.com/adminer.php
- If you're using the server's IP:
http://your_server_ip/adminer.php
You should see the Adminer login page.
- If you're using a domain:
-
Log in to Adminer: To log in, you need to provide the following details:
- System: Select your database type (e.g., MySQL, MariaDB, PostgreSQL).
- Server: Enter
localhost
or your database server IP address. - Username: Enter the username for your database (e.g.,
root
,admin
, or a custom user). - Password: Enter the password for your database user.
- Database: Optionally, select the specific database you want to manage or leave it blank to see all available databases.
-
Start Managing Databases: Once logged in, you can begin managing your databases using Adminer’s user-friendly interface.
Step 6: Secure Adminer
While Adminer is a great tool, you should take measures to secure it, especially when it is publicly accessible.
-
Change the Adminer File Name: Changing the filename of the
adminer.php
file can help reduce the chances of automated attacks. Rename it to something less predictable:Update your web browser URL accordingly (
http://your_server_ip/custom_adminer.php
). -
Restrict Access to Adminer: You can limit access to Adminer by IP address or password protection using
.htaccess
.-
Restrict by IP: You can restrict access to Adminer to specific IP addresses by modifying the Apache configuration:
Add the following inside the
<Directory /var/www/html>
block:Replace
192.168.1.100
with the IP address you want to allow access to Adminer. -
Password Protect Adminer: To add an additional layer of security, use HTTP authentication to protect Adminer. Install the necessary tools:
Create a password file:
Then, update the Apache configuration:
Add the following lines inside the
<Directory /var/www/html>
block:Restart Apache to apply the changes:
-
Conclusion
You have successfully installed and configured Adminer on your VPS for database management. With Adminer, you can easily manage your MySQL, PostgreSQL, SQLite, and other databases from a web interface. Remember to secure your Adminer installation to prevent unauthorized access.
Now, you can efficiently manage your databases directly from your browser, making database administration much easier.