Video illustration of how to install and configure phpMyAdmin on Amazon Linux 2023

Introduction

While many users need the functionality of a database management system like MySQL, they may not feel comfortable interacting with the system solely from the MySQL prompt.

phpMyAdmin was created so that users can interact with MySQL through a web interface. In this guide, I will show you how to install and configure phpMyAdmin so that you can use it to manage your databases on an Amazon Linux 2023 system.

Prerequisite

Complete tutorial: How to setup an Amazon EC2 instance and install LAMP stack on Amazon Linux 2023.

Steps

1. Login to the AWS Cloud Console, find and connect to (or SSH into) the server instance.

2. Create a dedicated user for phpMyAdmin

I recommend connecting to phpMyAdmin with a dedicated user. To do this, open up the MySQL shell once again:

mysql -u root -p

From there, create a new user and give it a strong password:

CREATE USER ‘vincent’@’localhost’ IDENTIFIED BY ‘User@789dynamic!’;

Then, grant your new user appropriate privileges. For example, you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command:

GRANT ALL PRIVILEGES ON *.* TO ‘vincent’@’localhost’ WITH GRANT OPTION;

Following that, exit the MySQL shell:

exit

Install needed packages and phpMyAdmin

Install necessary dependencies: 

sudo dnf install php-mbstring php-xml -y

Restart Apache: 

sudo systemctl restart httpd

Restart php-fpm: 

sudo systemctl restart php-fpm

Navigate to the Apache document root at /var/www/html: 

cd /var/www/html

Select a source package for the latest phpMyAdmin release from https://www.phpmyadmin.net/downloads. To download the file directly to your instance, copy the link and paste it into a wget command, as in this example: 

sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

Create a phpMyAdmin folder and extract the package into it with the following commands: 

sudo mkdir my-unique-phpMyAdmin 

sudo tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C my-unique-phpMyAdmin --strip-components 1

Change to the directory where we unpacked phpMyAdmin tarball file:

cd my-unique-phpMyAdmin

Confirm that your phpMyAdmin files are in the directory:

ls

Copy and edit configuration file:

sudo cp config.sample.inc.php config.inc.php

sudo nano config.inc.php

phpMyAdmin uses the cookie authentication method by default, which allows you to log in to phpMyAdmin as any valid MariaDB user with the help of cookies. In this method, the MariaDB user password is stored and encrypted with the Advanced Encryption Standard (AES) algorithm in a temporary cookie.

Historically, phpMyAdmin instead used the Blowfish cipher for this purpose, and this is still reflected in its configuration file. Scroll down to the line that begins with $cfg[‘blowfish_secret’]. It will look like this: 

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

In between the single quotes, enter a string of 32 random characters. This isn’t a passphrase you need to remember, it will just be used internally by the AES algorithm:

/usr/share/phpmyadmin/config.inc.php

For example:

$cfg['blowfish_secret'] = '2#!$%*HTEshdhcyc#@)(?+>!~*%@4vb^%mx&)*qmxz@!vcLP*$';  /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Save and exit the config.inc.php file

Exit the my-unique-phpMyAdmin directory and to the Apache document root directory:

cd ..

Delete the phpMyAdmin-latest-all-languages.tar.gz tarball: 

sudo rm phpMyAdmin-latest-all-languages.tar.gz

(Optional) If the MySQL server is not running, start it now:

sudo systemctl start mariadb

In a web browser, type the URL of your phpMyAdmin installation. This URL is the public DNS address (or the public IP address) of your instance followed by a forward slash and the name of your installation directory. For example: http://my.public.dns.amazonaws.com/my-unique-phpMyAdmin 

You should see the phpMyAdmin login page:

Log in to your phpMyAdmin installation with dedicated user name and the MySQL user password you created earlier.

Conclusion

You should now have phpMyAdmin configured and ready to use on your Amazon Linux 2023 server. Using this interface, you can create databases, users, and tables, as well as perform the usual operations like deleting and modifying structures and data.

END

References

  1. How to setup an Amazon Elastic Compute Cloud instance and install Linux, Apache, MariaDB and PHP (LAMP Stack) on Amazon Linux 2023.
  2. How to deploy a pre-built website from a code source into an EC2 web server on AWS.
  3. How to install and configure WordPress on Amazon Linux 2023.
  4. Install LAMP on Amazon Linux 2023.
  5. Caseray Cloud.
  6. My (Ugochukwu Ukwuegbu’s) YouTube channel.