How to Install phpMyAdmin with LAMP on Ubuntu 16.04

phpMyAdmin is a MySQL/MariaDB web administration tool. In this tutorial, we’re going to learn how to install phpMyAdmin with LAMP (Apache, MariaDB, PHP7) on Ubuntu 16.04. It is assumed that you have already installed LAMP stack on Ubuntu 16.04. If not, please check out the following tutorial.

Once LAMP is installed, let’s install phpMyAdmin.

Installing phpMyAdmin on Ubuntu 16.04

phpMyAdmin is included in Ubuntu 16.04 software repository. so we can easily install it with the command below

sudo apt update
sudo apt install phpmyadmin

The above command will install all necessary dependencies including PHP7 extensions. During the installation, it will prompt you to select a web server to configure. Hit the space bar to select apache2. An asterisk means that the item is selected. Then hit Tab key and Enter to confirm your choice.

phpmyadmin lamp

In the next screen, select Yes.

phpmyadmin apache config

Then set a password for the phpmyadmin user in MariaDB/MySQL.

phpmyadmin ubuntu 16.04

Once this step is done, you will find that a new database named phpmyadmin is created in MariaDB. Next, enable mcrypt and mbstring extension.

sudo phpenmod mcrypt

sudo phpenmod mbstring

Reload Apache for the changes to take effect.

sudo systemctl reload apache2

Now you can access phpMyAdmin web interface via

your-server-ip/phpmyadmin

You can use MariaDB/MySQL username and password to login.

phpmyadmin ubuntu

It is recommended that you always access phpMyAdmin over a secure HTTPS connection. If you have installed other web applications like WordPress and enabled HTTPS on those web applications on the same Ubuntu 16.04 system, then simply add /phpmyadmin after your domain name like below.

your-domain.com/phpmyadmin

install phpmyadmin ubuntu

And now you can manage your MariDB/MySQL databases via a web interface.

To use .htaccess in phpMyAdmin, we need to add AllowOverride All  directive in Apache configuration files.

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

Add AllowOverride All directive within <Directory /usr/share/phpmyadmin> like below

<Directory /usr/share/phpmyadmin>
  Options FollowSymLinks
  DirectoryIndex index.php
  AllowOverride All

If there’s no AllowOverride All directive, then it will default to AllowOverride none which disable .htaccess file.

Save and close the file. Then reload Apache.

sudo systemctl reload apache2

That’s it!

I hope this tutorial helped you install phpMyAdmin with LAMP on Ubuntu 16.04. As always, if you found this post useful, then subscribe to our free newsletter. You can also follow us on Google+ Twitter or like our Facebook page.

Rate this tutorial
[Total: 8 Average: 4.5]

One Response to “How to Install phpMyAdmin with LAMP on Ubuntu 16.04

  • ot the following after the sudo phpenmod mcrypt

    WARNING: Module mcrypt ini file doesn’t exist under /etc/php/7.0/mods-available
    WARNING: Module mcrypt ini file doesn’t exist under /etc/php/7.0/mods-available

    Where did my phpadmin folder end up? I currently have an old folder on my USB’s www folder (used on an old Rapberry-Pi2) –
    phpMyAdmin-4.6.4-english SUB-FOLDER

    And when I try to run it, it says
    #1698 – Access denied for user ‘***’@’localhost’

    mysqli_real_connect(): (HY000/1698): Access denied for user ‘***’@’localhost’

    Will copying the new Phpadmin folder to my USB www solve this problem?

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here