Install phpMyAdmin, Nginx and MariaDB on Ubuntu 18.04 LTS Server
I have been playing with Ubuntu 18.04 LTS , soon to be released… I have it installed on VMware Workstation guest machine… In this test I learn how to install phpMyAdmin.
phpMyAdmin is a web-based tool that allows users to easily manage MySQL or MariaDB databases. If you’re not comfortable managing databases via Linux command line , you may want to use phpMyAdmin web interface to manage your databases instead.
phpMyAdmin relies on the LAMP or LEMP stack to function. LAMP or LEMP is a collection of open source software that enable dynamic websites and applications to function. So before getting phpMyAdmin to function, lets get LEMP installed.
This brief tutorial shows students and new users how to install phpMyAdmin with Nginx, MariaDB and PHP support on Ubuntu 18.04 LTS. This post should be short and easy to follow.
To get started, continue with the steps below:
Step 1: Install MariaDB Database Server
Run the commands below to install MySQL database server
sudo apt update sudo apt install mariadb-server mariadb-client
After installing the server above, run the commands below to set a root password, remove the test database and disable the root from logging on remotely.
sudo mysql_secure_installation
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Restart MariaDB server
sudo systemctl restart mariadb.service
Step 2: Install Nginx HTTP Server
Next, run the commands below to install Apache2 HTTP Web Server
sudo apt install nginx
Step 3: Configure Nginx HTTP Server
Now run the commands below to configure Nginx basic settings. These are the basics.. and more advanced configurations can be done later.
First, confirm that your Nginx server configuration has Nginx Index directives for php defined. To run PHP based apps, Nginx must have index.php as a directory index in its site config file.
sudo nano /etc/nginx/sites-available/default
Make sure index.php is defined on the Index line in the site configuration file… Also, make sure that the PHP FastcGI section highlighted below is no commented out.. Save the file and exit.
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name example.com www.example.com; # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } }
Save the file and restart Nginx
sudo systemctl restart nginx.service
Step 4: Install PHP-FPM and Related Modules
Run the commands below to install PHP and related PHP modules.
sudo apt-get install php-fpm php-cgi php-common php-pear php-mbstring
Step 5: Install phpMyAdmin
Now that Nginx 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, don’t select anything… just skip and continue. We’re using Nginx webserver and it’s not on the list, so just skip.
+------------------------+ 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 phpMyAdmin, run the commands below to create a symbolic link to phpMyadmin content.
sudo ln -s /usr/share/phpmyadmin /var/www/html
Now, open your web browser and login to the server hostname or IP address followed by phpmyadmin
ex. http://example.com/phpmyadmin

Logon with MySQL root account you created earlier…
That’s it!
If you get error #1698 – Access denied for user ‘root’@’localhost’ as shown in the image below, then read this post to fix.

Enjoy!

You may also like the post below:
Great guide! I have a problem with PHP pages: when I open a PHP page I get no errors but a completely white page. Any hint?
Superb…