Skip to content

How To Install and Secure phpMyAdmin on Ubuntu 20.04

Cloud Infrastructure Expert
How To Install and Secure phpMyAdmin on Ubuntu 20.04

 

 

phpMyAdmin is a popular tool for managing MySQL or MariaDB databases through a web interface. This tutorial will guide you through the installation and securing of phpMyAdmin on Ubuntu 20.04.

1. Update Your Package Index

Before installing phpMyAdmin, ensure your package index is up-to-date. Open your terminal and run:

sudo apt update

2. Install phpMyAdmin

Install phpMyAdmin with the following command:

sudo apt install phpmyadmin

During the installation, you will be prompted to choose the web server that should be automatically configured to run phpMyAdmin. Select apache2 using the space bar and then press Enter.

Next, you will be asked whether to use dbconfig-common to set up the database. Choose Yes and provide your MySQL/MariaDB root password to configure phpMyAdmin’s database.

3. Configure Apache to Serve phpMyAdmin

Ensure that the phpMyAdmin configuration file is included in Apache’s configuration. Run:

sudo nano /etc/apache2/apache2.conf

Add the following line at the end of the file:

Include /etc/phpmyadmin/apache.conf

Save and close the file (press Ctrl+X, then Y, and Enter).

4. Restart Apache

Apply the changes by restarting Apache:

sudo systemctl restart apache2

5. Secure phpMyAdmin

By default, phpMyAdmin is accessible without any additional security layers. To secure it, you can set up an additional authentication layer using Apache’s built-in authentication mechanism.

Create a Password File

Create a password file for user authentication:

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

Replace username with your desired username. You will be prompted to enter and confirm a password.

Configure Apache for Additional Security

Edit the phpMyAdmin Apache configuration file:

sudo nano /etc/phpmyadmin/apache.conf

Add the following configuration inside the <Directory /usr/share/phpmyadmin> block:


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

Save and close the file.

Restart Apache Again

To apply the new security settings, restart Apache:

sudo systemctl restart apache2

6. Access phpMyAdmin

Open a web browser and navigate to http://your_server_ip/phpmyadmin. You should see the phpMyAdmin login page. Enter the MySQL/MariaDB root credentials to log in. You will also be prompted for the additional authentication credentials you set up.

7. Keep phpMyAdmin Updated

Regularly update phpMyAdmin to ensure you have the latest security patches:

sudo apt update
sudo apt upgrade phpmyadmin

Windows VPS Deutschland

Windows VPS España

Windows VPS Nederland

Windows VPS Italia

Windows VPS Portugal

VPS Windows Italia

Windows VPS

Windows VPS

Windows VPS Sverige

Windows VPS Norge

Windows VPS

Windows VPS Türkiye

Windows RDS (Remote Desktop Services)

Windows VPS

Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.