Install and Secure phpMyAdmin with LAMP Stack on Ubuntu

Install and Secure phpMyAdmin with LAMP Stack on Ubuntu 20.04 LTS || Manoj Damor

Introduction: phpMyAdmin is a popular web-based graphical interface used to manage MySQL and MariaDB databases. It provides a user-friendly interface for performing database management tasks, making it an essential tool for developers and administrators. In this tutorial, we will guide you through the step-by-step process of installing and securing phpMyAdmin on Ubuntu 20.04 LTS, along with the LAMP (Linux, Apache, MySQL, PHP) stack.

Table of Contents:

  1. Prerequisites
  2. Install LAMP Stack on Ubuntu 20.04
  3. Install phpMyAdmin
  4. Configure Apache for phpMyAdmin
  5. Secure phpMyAdmin with an SSL Certificate
  6. Configure Authentication and Security
  7. Testing and Accessing phpMyAdmin
  8. Conclusion

1. Prerequisites

  • An Ubuntu 20.04 LTS server with a non-root user account and sudo privileges.
  • A LAMP stack installed and configured on your server. If you haven’t set up LAMP, refer to the official Ubuntu documentation.

2. Install LAMP Stack on Ubuntu 20.04

If you haven’t already installed the LAMP stack on your Ubuntu server, follow these steps to set it up:

  1. Update the package index and install Apache:
sudo apt update
sudo apt install apache2
  1. Install MySQL server and follow the prompts to set the root password:
sudo apt install mysql-server
sudo mysql_secure_installation
  1. Install PHP and necessary modules:
sudo apt install php libapache2-mod-php php-mysql

3. Install phpMyAdmin

Now, let’s proceed with the installation of phpMyAdmin:

  1. Install phpMyAdmin and its dependencies:
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
  1. Select “apache2” using the spacebar, and press Enter to continue.
  2. Set a password for the phpMyAdmin application database. Choose a strong password and confirm it.

4. Configure Apache for phpMyAdmin

To configure Apache to recognize and serve phpMyAdmin, follow these steps:

  1. Open the Apache configuration file for phpMyAdmin in a text editor:
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
  1. Find the line containing Require ip 127.0.0.1 and add your server’s IP address below it. You can find your IP address by running ip a or ifconfig commands.
  2. Save the file and exit the text editor.
  3. Enable the phpMyAdmin configuration by creating a symbolic link:
sudo ln -s /etc/apache2/conf-available/phpmyadmin.conf /etc/apache2/conf-enabled/phpmyadmin.conf
  1. Restart Apache for the changes to take effect:
sudo systemctl restart apache2

5. Secure phpMyAdmin with an SSL Certificate

To secure the phpMyAdmin interface with an SSL certificate, follow these steps:

  1. Install the SSL certificate package:
sudo apt install certbot
  1. Obtain an SSL certificate for your domain using Certbot:
sudo certbot --apache
  1. Follow the prompts to generate and install the SSL certificate.

6. Configure Authentication and Security

To enhance the security of your phpMyAdmin installation, it is recommended to enable authentication and implement additional security measures. Follow these steps:

  1. Open the phpMyAdmin configuration file in a text editor:
sudo nano /etc/phpmyadmin/config.inc.php
  1. Uncomment the line containing $cfg['Servers'][$i]['auth_type'] = 'cookie'; by removing the leading double slashes (//).
  2. Save the file and exit the text editor.
  3. Restart Apache for the changes to take effect:
sudo systemctl restart apache2

7. Testing and Accessing phpMyAdmin

To test your phpMyAdmin installation and access it through a web browser, follow these steps:

  1. Open URL:
https://your_domain_or_server_ip/phpmyadmin
  1. You will be redirected to the phpMyAdmin login page. Enter your MySQL database username and password.
  2. If the login is successful, you will be directed to the phpMyAdmin dashboard, where you can manage your MySQL databases and perform various tasks.

8. Conclusion

Congratulations! You have successfully installed and secured phpMyAdmin with the LAMP stack on Ubuntu 20.04 LTS. Remember to keep your server and phpMyAdmin installation up to date with the latest security patches and regularly review and implement additional security measures to protect your data.

Check My Social Profile Links

Instagram

Youtube

Website

About The Author

Install and Secure phpMyAdmin with LAMP Stack on Ubuntu 20.04 LTS || Manoj Damor

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow by Email
fb-share-icon
Share