Ubuntu 16.04 now ships with Nginx v1.10.3, PHP v7.0.30 and MariaDB v10.0.36. I had only got Nginx v1.4.6, PHP v5.6 and MySQL v5.7 with my old Virtualmin-Nginx setup on Ubuntu 14.04 LTS. That right there is a good reason to upgrade. I’ve tested this setup on my server and its working. It’s working great. You’ll clearly see performance improvements of your website.
And I’m sure you all heard about PHP v7.0.30 and how it’s so much better and faster than previous versions of PHP. Now you can enjoy its benefits on your server. And MySQL is gone. Instead Ubuntu 16.04 comes with MariaDB. But unfortunately Virtualmin still uses MySQL. But don’t worry, we’ll replace MySQL with MariaDB. There are so many good things to say, but I think we should get to the installation.
I’m going to assume that you already have a VPS with root access. If you don’t, you can get one from a unmanaged VPS provider I recommend. Logged in to Ubuntu 16.04 server as root user, run following command to check your server’s hostname.
If the output is anything other than your domain name or a sub-domain, you should change it before you install Virtualmin with nginx. Refer to change Ubuntu 16.04 hostname from command line tutorial and change it now.
Let’s start by updating apt cache,
apt update apt upgrade
Install Virtualmin with Nginx
This part is similar on all Linux distributions. Download the Virtualmin installation script to your server,
Run the script to install Virtualmin with nginx.
sh /root/install.sh -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.10.3, PHP v7.0.30 and MySQL v5.7. 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.
Instal Additional PHP 7.0 Modules
Virtualmin script installs PHP v7.0.30 on your server by default. If you need PHP version other than PHP v7.0.30, you can follow my instructions to use multiple PHP versions on your server. Although Virtualmin installs PHP v7.0.30 on your VPS, you’ll need few PHP modules installed on your server for most php applications to work. Following command will install essential PHP v7.0.30 modules on your server.
apt-get install memcached php7.0-mysql php7.0-curl php7.0-gd php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php7.0-zip
Replace MySQL with MariaDB
Virtualmin installs MySQL on the server by default. But I like to use MariaDB for my databases. MariaDB is a drop-in replacement for MySQL and is considered as an improved version of MySQL. So let’s remove MySQL. First stop MySQL,
service mysql stop
apt-get remove mysql-server mysql-common
apt-get install mariadb-server
That’s all you have to do to replace MySQL with MariaDB. Now Secure MariaDB.
Securing MariaDB Databases
There is more you can do to secure MariaDB databases. But at this point, running following command will guide you through changing some dangerous default settings. My input for the first question was No and Yes to everything else. It’ll also ask you for a new MariaDB password. You don’t need to change it here just type the same password you set on Virtualmin post-installation wizard.
Complete Virtualmin Post-Installation Wizard
You can access Virtualmin on following URL with your root password. Make sure you replace example.com with your domain name. Your DNS should be propagated for this to work. If DNS isn’t propagated yet, you can replace example.com 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.
That concludes Virtualmin-Nginx installation on Ubuntu 16.04. Your VPS is now fully configured to host websites using Nginx as the web server.