Home / Web Development / Virtualmin / Install Virtualmin, Nginx 1.10, PHP 7, MySQL 5.7 on Ubuntu 16.04 Server
ubuntu-16-04-nginx-php7-mariadb

Install Virtualmin, Nginx 1.10, PHP 7, MySQL 5.7 on Ubuntu 16.04 Server

Ubuntu 16.04 LTS was around for few months now. Today I got some free to check it out. It’s so much better than Ubuntu 14.04 I had been using. So I decided to upgrade my server to Ubuntu 16.04 LTS and thought it might be helpful to post a tutorial so my readers can upgrade their servers too.

Ubuntu 16.04 now ships with Nginx v1.10, PHP v7 and MySQL v5.7. You 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 7 and how it’s so much better and faster than previous versions of PHP. Now you can enjoy it’s benefits on your server. And MySQL is gone. It had been replaced by MariaDB. MariaDB offers more storage engines and it’s faster than MySQL. 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 providers I recommend. Logged in to Ubuntu 16.04 server as root user, run following command to output your server’s hostname.

hostname -f

If the output is anything other than your domain name or a sub-domain, you should change it before you install VIrtualmin. Refer to change Ubuntu 16.04 hostname from command line tutorial and change it now.

Installing Virtualmin

This part is similar on all Linux distributions. Download the Virtualmin installation script to your server,

wget http://software.virtualmin.com/gpl/scripts/install.sh

Run the script to install Virtualmin.

sh /root/install.sh

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 Apache 2.4, PHP 7 and MySQL 5.7. But since we’re interested in Nginx, we should stop Apache. Run following command to stop Apache. We will disable it later.

systemctl stop apache2.service

Installing Nginx

Now that the Apache is not running, you’ll be able to install Nginx. Following command will install it on your Ubuntu 16.04 server.

apt-get install nginx

Now install Virtualmin modules to support Nginx and Nginx SSL,

apt-get install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl

Installing PHP 7 Modules

Virtualmin script installs PHP 7 on your server by default. But some software, specially software that are ionCube encoded does not support PHP 7. Follow my instructions to downgrade PHP 7 to PHP 5.6 on Ubuntu 16.04 and then come back here to continue Vitualmin-Nginx installation. In that case, skip this section and continue to Running Virtualmin Post-Installation Wizard section below.

You’ll need few PHP modules installed on your server for some php applications to work. Following command will install essential PHP 7 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

Running 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 eaxmple.com with your server’s IP address.

https://example.com:10000/

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

Configuring Virtualmin to enable Nginx

Virtualmin is configured to use Apache as http server at this moment. You can change this from Features and Plugins module. Go to System Settings -> Features and Plugins from your Virtualmin dashboard and,

Enable
  • Nginx website
  • Nginx SSL website
Disable
  • Apache website
  • SSL website
  • DAV Login
  • Mailman
  • Protected web directories
  • AWstats reporting
  • Subversion repositories

Save the changes and switch to Webmin from top-left corner. Then go to System -> Bootup and Shutdown. Check apache2 and click Disable On Boot at the bottom of page.

Securing MySQL Databases

There is more you can do to secure MySQL 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 ans Yes to everything else.

mysql_secure_installation

That concludes Virtualmin-Nginx installation on Ubuntu 16.04. Your VPS is now fully configured to host websites using Nginx as the web server.

namecheap namecheap

About Tharindu

Profile photo of Tharindu
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. send me a message on Fiverr.

8 comments

  1. Didnt had so couldnt remove

    DAV Login
    Mailman
    Subversion repositories

    Why AWstats reporting needs to be removed for nginx?

    I have only on fresh system now as of today installed only theese plugins

    BIND DNS domain
    Mail for domain
    Apache website
    Webalizer reporting
    SSL website
    Log file rotation
    MySQL database
    PostgreSQL database
    ProFTPD virtual FTP
    Spam filtering
    Virus filtering
    Webmin login
    AWstats reporting
    Nginx SSL website
    Nginx website
    Protected web directories

    On system info Status showing up

    BIND DNS Server
    Postfix Mail Server
    Dovecot IMAP / POP3 Server
    ProFTPD FTP Server
    SSH Server
    MySQL Database Server
    Nginx Webserver

  2. Hey, I’m going through your steps after setting up a VPS Ubuntu on Google Cloud.

    I’ve went through all the steps yet I can’t access my server using my IP address and port 10000.

    In your explanation, you say that the hostname should be the domain name, but this server is not a website, I strictly want it to use Prosper202, so I’m trying to follow your steps to do that.

    During the installation process of Virtualmin, It asked me for my fully qualified domain name. I didn’t really have one so I just made one up.

    I have a feeling this could be a problem why I can’t connect to my system to go through the Post-Installation Wizard.

    I’ve made sure all firewalls are off, ive restarted the system, and I’m trying to connect directly to the instance with https://[IP Address]:10000

    What else could I do to troubleshoot why I can’t connect?

    Thanks for all your help!

    • Profile photo of Tharindu

      Prosper202 needs a domain name or subdomain. You can use that same domain as FQDN for Virtualmin. It’s important to correct that. But that’s not the issue here.

      I haven’t used Google Cloud. But I have the feeling that there may be some sort of firewall on there network. Like that’s on AWS. Otherwise you should be able to connect on IP address regardless of FQDN.

      And this tutorial along will not be sufficient to get Virtualmin working on Google Cloud. You’ll have to configure networking on Virtualmin after post installation.

  3. Hello,

    Thank you very much for your Help!
    What about MariaDB running on Virtualmin + nginx ?

    Thanks!

    • Profile photo of Tharindu

      It’ll work. But since Virtualmin automatically installs MySQL, you’ll have to remove it manually and install MariaDB. And then you will need to configure Virtualmin to use MariaDB instead of MySQL.

  4. I keep getting errors such as –
    E: Unable to locate package webmin
    E: Unable to locate package usermin
    E: Unable to locate package procmail-wrapper
    E: Unable to locate package scponly
    .
    .
    .
    FATAL – Fatal Error Occured: Somthing went wrong during the installation.

    How can I get this to work?

Leave a Reply