How to Setup phpMyAdmin on Ubuntu 16.04 LAMP Server (Apache2 + PHP7)
| |Bringing more awesomeness within its new version release, the Ubuntu 16.04 has been also available as ready-to-use template on many of Cloud Server providers including Atlantic.net and Digital Ocean. This new Ubuntu server build has included PHP7, MariaDB, and phpMyAdmin in its repository. It means users can simply install those apps by simply using apt-get install command. However, some users may still be faced with common problem because the installation procedure has been done improperly.
In this article, you’ll see a proper method on how to install / setup world’s most popular MySQL management software, phpMyAdmin, on Ubuntu 16.04 server running Apache2, MariaDB and PHP7.
Prerequisites
- A SSH client like Bitvise or Putty and basic knowledge about how to use it.
- Basic knowledge about common Unix command to SSH to your server.
- A server or VPS with at least 256MB of RAM (OpenVZ) but 512MB is recommended if you are using KVM or Xen.
- About 30 minutes of your time.
- a cup of coffee or tea.
Confused on choosing which VPS provider to setup an Apache based hosting server? Read my recommended VPS providers or this list of top low end cloud server providers. Quick recommendation: Digital Ocean, Atlantic.net or Ramnode.
Prerequisites
- A SSH client like Bitvise or Putty and basic knowledge about how to use it.
- Basic knowledge about common Unix command to SSH to your server.
- A server or VPS with at least 256MB of RAM (OpenVZ) but 512MB is recommended if you are using KVM or Xen.
- About 30 minutes of your time.
- a cup of coffee or tea.
Confused on choosing which VPS provider to setup an Apache based hosting server? Read my recommended VPS providers or this list of top low end cloud server providers. Quick recommendation: Digital Ocean, Atlantic.net or Ramnode.
In this guide I am using a 512MB RAM Cloud VPS from Atlantic running Ubuntu 16.04 x64.
Do not forget to always replace domain.tld with your own domain name and replace x.x.x.x with your server IP address.
Install phpMyAdmin
Step 1 – First thing and the most important part, you have to install complete LAMP stack on Ubuntu 16.04 including PHP7, MariaDB server and Apache2 webserver.
Step 2 – Now install phpMyAdmin using this command :
apt-get install phpmyadmin
Step 3 – The installer will then ask you an option to use dbconfig-common to configure phpMyAdmin. Select Yes.
Step 4 – Now you have to define a password for phpmyadmin database.
You’ll then be asked once more to confirm the password.
Step 5 – Once finished, the phpMyAdmin should now been installed. However, in rare cases you may also end up with error message saying :
ERROR 1045 (28000) : Access denied for user ‘root’@’localhost’ (using password : NO). Your options are … (etc)
If that what happens, follow these additional steps :
First, Simply choose Abort.
Then login to mysql as root using the password you’ve defined when you install MariaDB.
mysql -u root -p
Next, issue following command :
CREATE DATABASE phpmyadmin; GRANT ALL ON phpmyadmin.* TO phpmyadmin@localhost IDENTIFIED BY 'changethispassword'; \q
Do not forget to replace changethispassword with your own password.
Next, edit database configuration :
nano /etc/phpmyadmin/config-db.php
then edit the dbpass parameter with the password you’ve just defined.
<?php ## ## database access settings in php format ## automatically generated from /etc/dbconfig-common/phpmyadmin.conf ## by /usr/sbin/dbconfig-generate-include ## ## by default this file is managed via ucf, so you shouldn't have to ## worry about manual changes being silently discarded. *however*, ## you'll probably also want to edit the configuration file mentioned ## above too. ## $dbuser='phpmyadmin'; $dbpass='changethispassword'; $basepath=''; $dbname='phpmyadmin'; $dbserver='localhost'; $dbport=''; $dbtype='mysql';
replace changethispassword with your own.
Again, hit Control+O to save and Control+X to exit Nano editor.
Step 6 – Install the required PHP7 modules (without this, your phpMyAdmin won’t work).
hence, issue this command :
apt-get install php-mbstring php7.0-mbstring php-gettext
Step 7 – Adjust Apache2 config file to make phpMyAdmin accessible :
nano /etc/apache2/apache2.conf
Step 8 – Scroll down the configuration page till the bottom and add this :
Include /etc/phpmyadmin/apache.conf
Save changes and exit Nano editor.
Step 9 – Restart Apache2 service :
service apache2 restart
Step 10 – Finally, open up your favorite web browser again and try accessing phpMyAdmin for the first time via this url :
http://x.x.x.x/phpmyadmin
replace x.x.x.x with your server IP address.
Use this credential for your first login:
- Username : root
- Password : MySQL password for root you have defined during installation (see section MariaDB Install at Step 2 – Step 3 here)
And you are in!
Once you have logged in, you can then manage your MySQL database using the graphical web based user interface. You can create new database, tables, database users, granting users access to specific database, and so on without having to login via Putty / Terminal again. That’s all and again, do not forget to follow me on twitter or subscribe using your email to get faster update on any new article.
Hello,
What about installing phpmyadmin on nginx only server?
I spent half the day installing and reinstalling phpmyadmin on my digitalocean ubuntu16.04 LAMP stack.
I could have missed it elsewhere but the edit to /etc/apache2/apache2.conf, adding
Include /etc/phpmyadmin/apache.conf
made it all happen.
Thank you very much.
Bill
Hello Servermom,
Lovely guide to refresh the process of installing phpmyadmin.
I just want to let you know that the figures under Step 5 and 6 doesn’t show.