How To Install and Secure phpMyAdmin on Ubuntu 18.04

How To Install and Secure phpMyAdmin on Ubuntu 18.04

How To Install and Secure phpMyAdmin on Ubuntu 18.04

Introduction

phpMyAdmin is a web-based application that provides a graphical user interface (GUI) to manage MySQL databases. In this tutorial, we will learn how to install and secure phpMyAdmin on Ubuntu 18.04.

Prerequisites

  • A server running Ubuntu 18.04.
  • A sudo user.
  • MySQL installed on your server.

Step 1: Update Your System

Before installing any package, it is always a good practice to update your system.

sudo apt update
sudo apt upgrade

Step 2: Install phpMyAdmin

Use the following command to install phpMyAdmin:

sudo apt install phpmyadmin

During the installation process, you will be prompted to choose a web server. Select apache2 and press Enter.

When asked whether to configure the database for phpMyAdmin with dbconfig-common, select Yes and press Enter.

You will then be prompted to enter the MySQL application password. Enter the password and press Enter.

Next, you will be prompted to set a password for phpMyAdmin. Choose a strong password and press Enter.

Step 3: Configure Apache

Open the Apache configuration file in your preferred text editor:

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.

Step 4: Restart Apache

Restart Apache for the changes to take effect:

sudo systemctl restart apache2

Step 5: Secure phpMyAdmin

By default, phpMyAdmin is not secured, which means that anyone with access to the URL can log in and access your database. To secure phpMyAdmin, we will create a new Apache configuration file.

Create a new configuration file:

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

Add the following lines to the file:

<Directory /usr/share/phpmyadmin>
  AllowOverride None
  Order Deny,Allow
  Deny from All
  Allow from localhost
  Allow from 127.0

Комментарии

Популярные сообщения из этого блога

How To Modify CSS Classes in JavaScript

How To Backup MySQL Databases on an Ubuntu VPS

How To Backup PostgreSQL Databases on an Ubuntu VPS