Install Nginx, MariaDB, PHP and PhpMyAdmin in Ubuntu 18.04

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

12 Responses

  1. subin babu says:

    Thanks, man, really helpful and I have a small doubt, I have a site which is using apache2, MySQL can I migrate apache2 to Nginx and also MySQL to MariaDB without any data loss.

    • Ravi Saive says:


      Yes, you can switch from Apache to Nginx and from MySQL to MariaDB without loosing any data.. Just remove the Apache, and install Nginx and point the Nginx DocumentRoot to your website directory. Similarly, take a dump of all databases from MySQL, remove it and install MariaDB and import all databases that’s it!

  2. Raphael Cabral says:

    Good tutorial, man!

    But, I needed to reload again at the end of everything, for phpmyadmin to work fine.
    (Using Kubuntu 18.04 LTS)

  3. Davide says:

    At first 16. (why two point 16?) there is a typo:


    should be:

  4. Martin says:

    Good tutorial!

    When you create a link there is a slash missing…

    On my computer the nginx is running as www-data so the chown command had to be modified

    • Federico says:

      Same here on a Ubuntu 18.04 server, however even after running the chown as root:www-data I still get an access denied on phpmyadmin. No clue why..

  5. Kent879 says:

    It seems to be something wrong with this tutorial…

    1. In Step 3 #8 installing php will pull in apache as a dependency and replace nginx with apache. I had to install only php-fpm for this to not happen.

    2. In Step 3 #12 and #13 i get error “502 Bad Gateway” when opening info.php (also tried with apache, same error). I’m able to open http://SERVER_IP but I get the error when opening http://SERVER_IP/info.php

    I’m stuck, help please?

    • Aaron Kili says:

      You encountering a “502 Bad Gateway” error because Nginx is proxying requests to a nonexistent upstream server or endpoint. Ensure that PHP-FPM service is running, check its status using following command.

      $ sudo systemctl status php7.2-fpm

      In case it is not up and running, start it.

      $ sudo systemctl start php7.2-fpm

      Also make sure that you have uncommented this section in your default server block file:

      location ~ \.php$ {
                  include snippets/fastcgi-php.conf;
              	fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;       #take note of this line, it should indicate PHP7.2
  6. Olivia says:

    Cool tutorial, very helpful, but vim instead of nano? I guess vim-users don’t need a tutorial :p

Got something to say? Join the discussion.

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.