GoranStimac.com



How To Install and Secure PhpMyAdmin on Ubuntu 20.04

phpMyAdmin was created so that users can interact with MySQL through a web interface. In this guide, we’ll discuss how to install and secure phpMyAdmin so that you can safely use it to manage your databases on an Ubuntu 20.04 system.

Step 1 — Installing phpMyAdmin

You can use apt to install phpMyAdmin from the default Ubuntu repositories.

As your non-root sudo user, update your server’s package index:

sudo apt update

Following that you can install the phpmyadmin package. Along with this package, the official documentation also recommends that you install a few PHP extensions onto your server to enable certain functionalities and improve performance.

If you followed the prerequisite LAMP stack tutorial, several of these modules will have been installed along with the php package. However, it’s recommended that you also install these packages:

  • php-mbstring: A module for managing non-ASCII strings and convert strings to different encodings
  • php-zip: This extension supports uploading .zip files to phpMyAdmin
  • php-gd: Enables support for the GD Graphics Library
  • php-json: Provides PHP with support for JSON serialization
  • php-curl: Allows PHP to interact with different kinds of servers using different protocols

Run the following command to install these packages onto your system. Please note, though, that the installation process requires you to make some choices to configure phpMyAdmin correctly. We’ll walk through these options shortly:

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

The installation process adds the phpMyAdmin Apache configuration file into the /etc/apache2/conf-enabled/ directory, where it is read automatically. To finish configuring Apache and PHP to work with phpMyAdmin, the only remaining task in this section of the tutorial is to is explicitly enable the mbstring PHP extension, which you can do by typing:

sudo phpenmod mbstring

Afterwards, restart Apache for your changes to be recognized:

sudo systemctl restart apache2

phpMyAdmin is now installed and configured to work with Apache. However, before you can log in and begin interacting with your MySQL databases, you will need to ensure that your MySQL users have the privileges required for interacting with the program.

Related Posts