Managing MySQL and MariaDB purely through the command line can be complex, especially for beginners. To simplify this process, administrators often choose to create phpMyAdmin, a browser-based interface that streamlines database tasks and makes management user-friendly.

In this article, we’ll guide you step by step on how to create and configure phpMyAdmin on a Linux server. We’ll cover prerequisites, installation, configuration, securing the setup, enabling remote access, common issues with fixes, and best practices. By the end, you’ll be able to manage databases easily through a web interface.
Prerequisites
Before you start the installation, ensure the following requirements are met:
- A Linux server (Ubuntu/Debian/CentOS preferred)
- MySQL or MariaDB is already installed and running
- Apache or Nginx web server configured
- PHP installed (since phpMyAdmin is PHP-based)
- Root or sudo access to the server
Without these, phpMyAdmin will not run properly.
Install phpMyAdmin on Linux
Installing phpMyAdmin on Linux is a simple process, but it requires careful attention to detail to ensure smooth functionality. Since phpMyAdmin depends on services like Apache/Nginx, PHP, and MySQL/MariaDB, each component must be properly configured beforehand. Once installed, phpMyAdmin provides a powerful and user-friendly interface to manage databases, users, and queries directly from your web browser.
- Update System Packages
sudo apt update && sudo apt upgrade -y # Ubuntu/Debian
sudo yum update -y # CentOS/RHEL
- Install phpMyAdmin
On Ubuntu/Debian:
sudo apt install phpmyadmin -y
During installation, you’ll be asked:
- Web server to configure (choose Apache2)
- Database setup for phpMyAdmin (select Yes and set a password)
For CentOS/RHEL, phpMyAdmin can be installed from the EPEL repository:
sudo yum install epel-release -y
sudo yum install phpmyadmin -y
Configuring phpMyAdmin on Linux
After installation, phpMyAdmin needs proper configuration to work securely and efficiently. This involves linking it with MySQL or MariaDB, setting up authentication, and restricting access to trusted users for safe database management.
- Apache Configuration
If you’re using Apache, ensure phpMyAdmin is enabled:
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo systemctl reload apache2
Now, phpMyAdmin should be accessible at:
http://your_server_ip/phpmyadmin
Nginx Configuration
For Nginx, manually configure phpMyAdmin by adding a location block inside the server block:
location /phpmyadmin {
root /usr/share/;
index index.php;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Reload Nginx:
sudo systemctl reload nginx
Securing phpMyAdmin Access
phpMyAdmin, being a web tool, is often targeted by attackers. Securing it is crucial.
- Change URL Path: Instead of
/phpmyadmin
, rename it to something unique:
sudo mv /usr/share/phpmyadmin /usr/share/secure_pma
- Enable Authentication with Apache/Nginx: Add
.htpasswd
protection to restrict access. - Allow Specific IPs: Configure firewall rules or web server config to allow only trusted IPs.
- Use SSL (HTTPS): Ensure phpMyAdmin traffic is encrypted with SSL certificates from Let’s Encrypt or another provider.
Managing phpMyAdmin Services on Linux
phpMyAdmin doesn’t run as a separate service but relies on Apache/Nginx, MySQL, and PHP. To ensure smooth functioning:
- Restart Apache:
sudo systemctl restart apache2
- Restart Nginx:
sudo systemctl restart nginx
- Restart MySQL:
sudo systemctl restart mysql
- Restart PHP:
sudo systemctl restart php7.4-fpm
Enabling Remote Access to phpMyAdmin
Sometimes, you may need to access phpMyAdmin from another system.
- Modify Apache Configuration
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require ip YOUR_IP_ADDRESS
</Directory>
Replace YOUR_IP_ADDRESS
with the trusted IP.
Firewall Rules
If using UFW:
sudo ufw allow from YOUR_IP_ADDRESS to any port 80
sudo ufw allow from YOUR_IP_ADDRESS to any port 443
Common Issues and Fixes in phpMyAdmin
- 403 Forbidden Error → Check Apache/Nginx permissions and ensure correct directory access.
- Login Failure → Verify MySQL credentials and reset user privileges if needed.
- Timeout or Slow Loading → Increase PHP execution time and memory in
php.ini
. - “phpMyAdmin not found” → Re-check symbolic link or Nginx config file.
These quick fixes can resolve most problems without much downtime. And by identifying these problems early, you can quickly fix PHPMyAdmin firewall issues in Linux.
Conclusion
phpMyAdmin makes managing MySQL and MariaDB databases on Linux servers much easier with its intuitive web interface. From installation and configuration to securing access and troubleshooting issues, you now have the knowledge to set it up correctly. By combining phpMyAdmin with firewall rules, SSL, and restricted access, you can safely manage databases without worrying about security breaches.
Database administration doesn’t have to be limited to the command line. With phpMyAdmin, even complex tasks like creating databases, managing users, and running queries become straightforward. For more details and advanced configuration options, always refer to the official phpMyAdmin documentation.