Installing phpMyAdmin, Apache2, MySQL and PHP on Ubuntu 17.04 | 17.10

phpMyAdmin is a web-based tool that allows webmasters and students to easily manage MySQL or MariaDB databases. If you’re not an advanced database administrator, you may want to use phpMyAdmin web interface to manage your databases instead of using the command line terminal.

phpMyAdmin depends on the LAMP stack to function. LAMP is a combination of opensource software that enable dynamic websites and applications to function. So before getting phpMyAdmin to function, lets get LAMP installed.

This brief tutorial shows students and new users how to install phpMyAdmin with Apache2, MySQL and PHP support on Ubuntu 17.04 | 17.10. This post should be short and easy to follow.

In our previous post, we showed students and new users how to install phpMyAdmin with MariaDB support. You can read this post from there.

Before continuing below, please make sure you’ve installed MySQL database server.. To to install it, run the commands below..

sudo apt-get update
sudo apt-get install mysql-server mysql-client

Continue below with installing Apache2, PHP and phpMyAdmin

Step 1: Install and Configure Apache2

First, run the commands below to install Apache2.

sudo apt-get install apache2

Step 2: Configure Apache2

Next, run the commands below to configure Apache2 basic settings. These are the basics.. and more advanced configurations can be done later.

Change your Apache2 server token to Prod

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

Change the highlighted line below and save the file.

# Set to one of:  Full | OS | Minimal | Minor | Major | Prod
# where Full conveys the most information, and Prod the least.
#ServerTokens Minimal
ServerTokens Prod
#ServerTokens Full

Next, configure the default DirectoryIndex directives.

sudo nano /etc/apache2/mods-enabled/dir.conf

Then change the highlighted line below and save.

<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.php

Next, configure your domain or server name

sudo nano /etc/apache2/sites-enabled/000-default.conf

Change the highlighted lines and save the file.

 <VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

After that restart Apache2.

sudo systemctl restart apache2

Step 3: Install PHP

Run the commands below to install PHP scripts.

sudo apt-get install php php-cgi libapache2-mod-php php-common php-pear php-mbstring

Step 4: Configure Apache2 to Use PHP

After install PHP and other related scripts, run the commands below to enable Apache2 to use PHP.

sudo a2enconf php7.1-cgi

Reload Apache2

sudo systemctl reload apache2

Step 5: Install phpMyAdmin

Now that Apache2 and PHP are installed the final step is to install phpMyAdmin and configure. To do that, run the commands below

sudo apt-get install phpmyadmin php-gettext

When prompted to choose the webserver, selecat apache2 and continue.

+------------------------+ Configuring phpmyadmin +-------------------------+
 | Please choose the web server that should be automatically configured to   |
 | run phpMyAdmin.                                                           |
 |                                                                           |
 | Web server to reconfigure automatically:                                  |
 |                                                                           |
 |    [*] apache2                                                            |
 |    [ ] lighttpd                                                           |
 |                                                                           |
 |                                                                           |
 |                                 <ok>                                      |
 |                                                                           |

When prompted again to allow debconfig-common to install a database and configure select No.

 +------------------------+ Configuring phpmyadmin +-------------------------+
 |                                                                           |
 | The phpmyadmin package must have a database installed and configured      |
 | before it can be used.  This can be optionally handled with               |
 | dbconfig-common.                                                          |
 |                                                                           |
 | If you are an advanced database administrator and know that you want to   |
 | perform this configuration manually, or if your database has already      |
 | been installed and configured, you should refuse this option.  Details    |
 | on what needs to be done should most likely be provided in                |
 | /usr/share/doc/phpmyadmin.                                                |
 |                                                                           |
 | Otherwise, you should probably choose this option.                        |
 |                                                                           |
 | Configure database for phpmyadmin with dbconfig-common?                   |
 |                                                                           |
 |                  <Yes>                   <No>                             |
 |                                                                           |

After installing, run the commands below to logon to the database server to enable phpMyAdmin root logon.

Now, open your web browser and login to the server hostname or IP address followed by phpmyadmin


phpmyadmin logon page on ubuntu

Logon with MySQL root account you created earlier when you installed the database server.

That’s it!

You may also like the post below:


  1. not work very annoying

  2. Daniel Choiniere

    Works perfect, but this line needs to changed from “sudo a2enconf php7.0-cgi” to “sudo a2enconf php7.1-cgi” also the line to run at the end of phpmyadmin installation is sudo ln -s /usr/share/phpmyadmin /var/www/html

  3. is it the same way if I use Ubuntu 18.04? or is there something different?

  4. Works perfect, but this line needs to changed from “sudo a2enconf php7.1-cgi” to “sudo a2enconf php7.2-cgi”

  5. Noorul Shajitha Banu

    Are you sure you followed this correctly?

    When the first prompt appears, apache2 is highlighted, but not selected. If you do not hit "SPACE" to select Apache, the installer will not move the necessary files during installation. Hit "SPACE", "TAB", and then "ENTER" to select Apache.

    This is a very important part of step one that i’ve overlooked before that can cause this problem

    As another remedy you could try this:

    From the docs:

    If this does not work, then you can do the following to include the phpMyAdmin-shipped Apache configuration into Apache:

    sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
    sudo /etc/init.d/apache2 reload

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.