While MySQL prompt is used and recommended by the developer community for database administration, most people prefer a graphical user interface over the old school command line prompt. As of this writing, only a few database administrator applications are available to provide a web interface. PhpMyAdmin is the most popular for MySQL database management system.
This guide will help you to install phpMyAdmin on your ubuntu server with the best practices by the developer community.
System Requirements:
- Ubuntu 22.04 server
- A working LAMP stack installed.
If you are on a fresh Ubuntu installation, you can install LAMP stack first before continue to the guide. We will cover post-configuration for apache web server.
Install phpMyAdmin on Ubuntu 22.04 for apache
Phpmyadmin package is already available on the Ubuntu’s official package repository. It requires some additional php modules to function phpmyadmin properly. We will start by refreshing the package repository, then install phpmyadmin along with the php modules.
sudo apt update
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
The installation script will ask whether to use apache or lighthttpd as web server, choose apache
.
For the dbconfig-common prompt, Select Yes to set up the database
Then you will be asked to choose and confirm a MySQL application password for phpMyAdmin.
To complete configuring apache and PHP to work with phpMyAdmin we need enable the mbstring
PHP extension.
sudo phpenmod mbstring
Then restart apache for change to take effect.
sudo systemctl restart apache2
PhpMyAdmin is installed and configured to work with Apache (LAMP stack).
To access the phpmyadmin interface, go to :
https://server_domain_or_IP/phpmyadmin
Securing phpMyAdmin on Ubuntu 22.04 for Apache
Here are a few steps you can take to secure your PHPMyAdmin installation on an Apache server:
- Use SSL/TLS to encrypt traffic between the client and the server. This will help prevent eavesdropping and man-in-the-middle attacks.
- Restrict access to PHPMyAdmin to specific IP addresses or networks. This can be done using Apache’s Allow and Deny directives. For example:
<Location /phpmyadmin>
Allow from 192.168.1.0/24
Deny from all
</Location>
- Use HTTP authentication to require a username and password to access PHPMyAdmin. You can use Apache’s built-in HTTP authentication module or an external authentication module like mod_auth_basic.
- Use a different URL for PHPMyAdmin than the default. For example, instead of using /phpmyadmin, you could use a URL like /pma or /database-admin. This can make it more difficult for attackers to find your PHPMyAdmin installation.
- Keep your PHPMyAdmin installation up to date. New versions of PHPMyAdmin often include security fixes and improvements, so it’s important to keep your installation up to date.
- Consider using a tool like Fail2ban to protect against brute-force login attempts. Fail2ban can monitor your server logs and block IP addresses that are making repeated failed login attempts.
By following these steps, you can help secure your PHPMyAdmin installation and protect it from potential attacks.
Thanks alot 🙂 without your Thread i will have little troubles configuring this 😉 works great !
Thanks
This guide helps me to install LAMP stack in my ubuntu vm 🤗