How to Install phpMyAdmin in Ubuntu

In this article, I’ll show you how to install phpMyAdmin on an Ubuntu system step-by-step. phpMyAdmin is a popular web-based tool for managing MySQL or MariaDB databases, making it easier to interact with your databases through a user-friendly interface.

Whether you're a developer or a beginner, this guide will help you set it up quickly and efficiently.

Steps to Install phpMyAdmin in Ubuntu:

Update System Packages:

Start by updating your package list to ensure the latest versions are installed

sudo apt update
sudo apt upgrade -y

 

Install phpMyAdmin:

Run the following command to install phpMyAdmin and its dependencies:

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

During installation:

  • Select apache2 when prompted to choose a web server.
  • Press Tab to highlight "OK," then press Enter.
  • Provide a password for the phpMyAdmin user when prompted.

 

Enable Required PHP Extensions:

Enable necessary PHP extensions by running

sudo phpenmod mbstring

 

Restart Apache to apply the changes:

sudo systemctl restart apache2

 

Configure Apache for phpMyAdmin:

To make phpMyAdmin accessible, create a configuration file:

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Add the following content:

Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
    Options Indexes FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All
    Require all granted
</Directory>

Enable the configuration and restart Apache:

sudo a2enconf phpmyadmin
sudo systemctl restart apache2

 

Access phpMyAdmin:

Open a web browser and navigate to:

http://your-server-ip/phpmyadmin

Log in with your MySQL username and password to access the phpMyAdmin interface.

 

Secure phpMyAdmin (Optional):

To enhance security, create a password-protected directory for phpMyAdmin:

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Add the following under <Directory /usr/share/phpmyadmin>

AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

Create a .htpasswd file and add a user.

sudo htpasswd -c /etc/phpmyadmin/.htpasswd username

Restart Apache:

sudo systemctl restart apache2

 


You might also like:

techsolutionstuff

Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of techsolutionstuff.com. Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.

RECOMMENDED POSTS

FEATURE POSTS