Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we’ll walk you through the process of installing and securing phpMyAdmin, a powerful web-based tool for managing MySQL databases. Whether you’re a seasoned Ubuntu user or just getting started, follow these instructions to install and secure phpMyAdmin on your Ubuntu 22.04 server.
Table of Contents
Why phpMyAdmin?
Before we dive into the installation process, let’s briefly discuss why phpMyAdmin is a popular choice for managing MySQL databases. phpMyAdmin provides a user-friendly web interface, making it easy for both beginners and experienced database administrators to interact with MySQL databases. With features such as SQL query execution, database structure management, and user account administration, phpMyAdmin streamlines the database management process.
Install and Secure phpMyAdmin on Ubuntu 22.04
Step 1: Update and Upgrade Your System
Before installing any new software, it’s essential to ensure that your system is up-to-date. Open your terminal and run the following commands:
$ sudo apt update
$ sudo apt upgrade
Step 2: Update Repositories
Start by updating the repositories to ensure you get the latest version of phpMyAdmin:
sudo apt install software-properties-common
sudo add-apt-repository ppa:phpmyadmin/ppa
Step 3: Install phpMyAdmin
Now, install phpMyAdmin using the following command:
sudo apt install phpmyadmin
During the installation, you’ll be prompted to choose a web server. Select your preferred server (e.g., Apache or Nginx) and complete the installation.
Step 4: Configure phpMyAdmin
After installation, configure phpMyAdmin by editing the configuration file:
sudo nano /etc/phpmyadmin/config.inc.php
Look for the line that reads $cfg['blowfish_secret']
and set a unique passphrase. Save and exit the file.
Securing phpMyAdmin
Step 5: Implement Authentication
To enhance security, it’s crucial to set up an authentication process. Create a new user specifically for phpMyAdmin:
sudo mysql
CREATE USER 'phpmyadminuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadminuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
Step 6: Configure Firewall
Allow external access to phpMyAdmin by configuring your firewall. If using UFW:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
Step 7: Enable HTTPS
Encrypt your phpMyAdmin connection by installing and configuring a free SSL certificate from Let’s Encrypt:
sudo apt install certbot
sudo certbot --nginx
Transition to Advanced Security Measures
Now that the installation and basic security are in place, let’s explore advanced security measures.
Step 8: Change phpMyAdmin URL
To add an extra layer of security, change the default phpMyAdmin URL. Edit your web server configuration file:
sudo nano /etc/nginx/sites-available/default # or apache2 if using Apache
Add the following line inside the server block:
location /your_custom_url {
alias /usr/share/phpmyadmin;
}
Restart your web server:
sudo systemctl restart nginx # or apache2 if using Apache
Conclusion
Congratulations! You’ve successfully installed and secured phpMyAdmin on Ubuntu 22.04. By following these steps, you’ve not only unlocked the potential of this powerful database management tool but also fortified it against potential security threats.
Also Read Our Other Guides :
- How To Install MySQL 8.0 on Debian 11
- How To Install MySQL 8.0 on Rocky Linux 9
- How To Install MariaDB 10.9 on Debian 11 Server
- How To Install MariaDB 10.6 on Debian 11 Server
- How To Install MariaDB 10.6 on Ubuntu Server 22.04
As I have shown, now you have learned howto install and secure phpMyAdmin on your Ubuntu 22.04 server.