Install Virtualmin, Nginx 1.18, PHP 7.4, MySQL 5.7 on Ubuntu 18.04 Server

Step-by-step instructions to configure a superfast webserver with Virtualmin control panel and Nginx webserver

We at have been using Ubuntu 16.04 for our server setups for few years now. But with the EoL of Ubuntu 16.04 closing in on April 2021, we’ve decided to move to Ubuntu 18.04. As should our readers. This tutorial will show you how to install Virtualmin with Nginx on a Ubuntu 18.04 server.

Ubuntu 18.04 ships with slightly newer versions of software including Nginx 1.18 and PHP 7.3. But in this tutorial, we will be setting up PHP v7.4 as the default version of PHP for websites with ability to have all major PHP versions. This can be easily done thanks to Virtualmin.

We’re dropping MariaDB as it has many incompatibles with our setup. It’s simply not worth the time to make it work at this time. So let’s get started. First step is obviously get a VPS that can house Virtualmin and all other software. We recommend a 2GB RAM server as the minimum and 4GB RAM server for best performance. But please note that amount of server resource you will need depend on your website. Please head over to our recommended unmanaged VPS providers list and get a server with Ubuntu 18.04 as the operating system. Once you have root access to the server, you’re ready to install Virtualmin with nginx on Ubuntu 18.04.

I’m going to assume you already know how to login to your VPS using SSH. Let’s start by setting up a proper hostname for your Ubuntu 18.04 VPS. With that completed, let’s move on to building the server.

Add Ondřej Surý Repo to Ubuntu 18.04 Server

Ubuntu 18.04 comes with PHP v7.2. Which isn’t the latest version of PHP available. For that reason, we’re going to use Ondřej Surý’s PHP repository to get the latest compatible version of PHP for our setup. Ondřej Surý is a well known Debian Developer. Using his repositories will allow us to install the latest version of PHP on our system or even have multiple PHP versions running at the same time if we need to. Following command will add ondrej/php PPA to the system.

add-apt-repository ppa:ondrej/php

Trouble with add-apt-repository?

We will also add ondrej/nginx PPA to the system so we can get the latest nginx version.

add-apt-repository ppa:ondrej/nginx

Update apt cache,

apt update
apt upgrade

Install Virtualmin with Nginx on Ubuntu 18.04 Server

We will be using the bash script provided by Virtualmin developers for the installation. It’s the easiest way to install Virtualmin. Following command will fetch the bash script to your server.


The script will try to install Apache2 as the webserver. So we will manipulate the install command to skip that and tell Virtualmin to build our server with Nginx instead.

sh /root/ -b LEMP

You’ll be asked to confirm the action. Confirm it and Virtualmin installation will begin. It’ll take few minutes for the installer to complete. It’ll setup Nginx v1.18, PHP v7.2 and MySQL v5.7 on the server. You’ll be asked for permission to a swap file if your server has less than 1GB of RAM. You’ll be greeted with following message on your Putty screen when Installation completed.


Install PHP v7.4 and Additional Modules on Ubuntu 18.04 server

If you have noticed earlier, Virtualmin installs PHP v7.2 during the installation. But PHP v7.2 is considered outdated now. So, we will install PHP v7.4 alongside it and set v7.4 as the default version for websites. This will allow us to use both versions on our server. It’s especially helpful for software that doesn’t support PHP v7.4 yet. Following command will install PHP v7.4 with some commonly used modules.

apt install php-pear php-imagick php7.4-cgi php7.4-fpm php7.4-mysql php7.4-curl php7.4-gd php7.4-imap php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-mbstring php7.4-zip php7.4-cli php7.4-soap

Now you need to make sure server is using correct PHP version for the command php. If your php application requires setting up cronjobs, this step is mandatory, or your application will misbehave.

update-alternatives --set php /usr/bin/php7.4

Above command sets PHP v7.4 as the default PHP version for command line.

It’s possible to have more than one PHP version installed on your server. Please read How to use multiple PHP versions with Virtualmin and Nginx for more information on that.

Secure MySQL Installation on Ubuntu 18.04 server

MySQL comes with some dangerous default settings. This section only focus on securing those. There are more to securing a MySQL installation than this. But running this simple command and following on-screen instructions will give you some comfort that your databases are secure.
My input for the first question is a No and Yes to everything else.

Complete Virtualmin Post-Installation Wizard

You can access Virtualmin on following URL with your root password. Make sure you replace with your domain name. Your DNS should be propagated for this to work. If DNS isn’t propagated yet, you can replace with your server’s IP address.

You’ll be taken to the Virtualmin Post-Installation Wizard after the login. It is pretty self-explanatory, just remember to select MySQL/MariaDB as database server and Only store hashed passwords as password storing method. You’ll be good with default selections for all other steps.

You’ll be given an option to check Virtualmin configurations after the Post-Installation wizard. Click Recheck and refresh configuration button to check your server for errors. The most common error I’ve encountered was system is not setup to use itself as a DNS server. If everything goes well, you’ll be greeted with .. your system is ready for use by Virtualmin.

This concludes Virtualmin and LEMP installation for now. But there are few more things you need to do to make sure your server has optimal configuration to host websites. I’ll guide you through them on Virtualmin Post-Installation Configuration and Server Optimization tutorial.


Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Related Articles


  1. I got stuck about 2 hours in phase 2 installing virtualmin-lamp-stack I’m using ec2 micro free tier.
    what am I doing wrong?

    1. Did you get an error? If yes, create a topic on our forum with the error you got. And the issue you are having might be low resources and heavy throttling AWS has. Try using unlimited CPU option or use a higher instance.

      1. no nthng happened it just stuck. that tiny installation bar is half full, I can’t tell if it’s still going or stuck. I have no tech knowledge and following your instruction to run sendy on aws but got stuck here, what should I do?

          1. how can i do that? do you have guide for that, and what should I do now with stuck app? Do I have to do anything before closing it ?

  2. 9 Apr 16:51:13 ntpdate[8394]: adjust time server offset 0.001685 sec
    it always shows this while installing virtualmin in my vps

Leave a Reply

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

Back to top button