# How to Install and Secure phpMyAdmin in Ubuntu 14.04

> URL: https://www.atlantic.net/vps-hosting/how-to-install-secure-phpmyadmin-ubuntu-14-04/ | Published: 2015-02-07 | Updated: 2024-06-06 | Author: Jose Velazquez

##### Verified and Tested 01/31/2015

### Introduction

This document will help you install phpMyAdmin and describe some basic steps to take in order to secure it.

## Prerequisites

You need an Ubuntu 14.04 server that is configured with a static IP address.

You will also need to have LAMP (Linux, Apache, MySQL and PHP) installed on the server.

## Installing phpMyAdmin

Install phpMyAdmin

```
sudo apt-get install phpmyadmin
```

phpMyAdmin is now installed on your server. Now we begin the Apache configuration.

 

Setup phpMyAdmin under Apache, edit the apache2.conf file.

```
sudo nano /etc/apache2/apache2.conf
```

Add the following code to the bottom of the apache2.conf file.

```
Include /etc/phpmyadmin/apache.conf
```

![Add your config file for phpmyadmin](https://www.atlantic.net/wp-content/uploads/2018/01/php1-5.png)

apache2.conf

Save your changes by pressing **Ctrl + X** then **Y** to accept.

Restart Apache.

```
sudo service apache2 restart
```

Verify that your installation works, type the following link in your browser http://YOURIP/myphpadmin

**(Log in with the username and password that was created during the installation)**

## Securing myPHPAdmin

Setup security for phpMyAdmin, edit the apache.conf file:

```
sudo nano /etc/phpmyadmin/apache.conf
```

Locate the **<Directory /usr/share/phpmyadmin>** and add the following rule under **DirectoryIndex index.php**

```
AllowOverride All
```

 

![Add directive AllowOveride All to apache.conf](https://www.atlantic.net/wp-content/uploads/2018/01/php2-4.png)

apache.conf

Save your changes by pressing **Ctrl + X** then **Y** to accept.

Create the .htaccess file that will handle the authentication.

```
sudo nano /usr/share/phpmyadmin/.htaccess
```

Paste the following text in the file:

```
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/apache2/.phpmyadmin.htpasswd
Require valid-user
```

![Sample: .htacess](https://www.atlantic.net/wp-content/uploads/2018/01/php3-4.png)

Sample: .htacess

Save your changes by pressing **Ctrl + X** then **Y** to accept.

Create a user and password that you would like to use for security access by pasting the following code. Then you will enter and re enter your password. (Note:Replace username with the actual user that you want to create. I will be using admin).

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

Restart Apache.

```
sudo service apache2 restart
```

Verify that everything works by typing the following link in your browser http://YOURIP/myphpadmin and typing your security username and password

![Sample Login Prompt](https://www.atlantic.net/wp-content/uploads/2018/01/php4-4.png)

Sample Login Prompt

Congratulations! You have just installed and secured phpMyAdmin on your server. Thank you for following along in this How-To and feel free to check back with us for any new updates.

## Atlantic.Net

Since 1995, Atlantic.Net has been providing internet services to customers, including managed, cloud, and [vps hosting](https://www.atlantic.net/vps-hosting/).  In 20+ years of service, our solutions have been focused on providing the very best in web solutions to our valued customers!
