Setting up Virtualmin Control Panel with Nginx on Ubuntu 14.04 LTS

Virtualmin is among the very few hosting control panels that support Nginx. Until now I configured my client’s servers without a control panel. It’s wasn’t much of an issue, but I received mixed comments about it time to time. Specially from people who are used to shared hosting. So I went searching for a control panel that supports Nginx.

Ubuntu 16.04 LTS is now available and setting up Virtualmin on it offers more security and performance improvements. Ubuntu 16.04 LTS comes with Nginx 1.10, PHP 7 and MariaDB 10. You can follow my Ubuntu 16.04 LEMP stack tutorial to set it up on your server

The solution is Virtualmin. Although it doesn’t support Nginx out of the box, it can be enabled with little configuration and a plugin. In this post, I’m going to walk you through the steps of configuring an unmanaged VPS with Virtualmin and Nginx. This configuration will create the platform to host websites based on WordPress and alike. I’ve tested Prosper202 on this setup and found it working without errors.

Before we start, I’m going to assume that you have an unmanaged VPS with root access ready to go. If not, you can get one from best unmanaged VPS providers. Do not try this on a server that is already setup. This tutorial is only intended for fresh servers. And also, it’s important that your VPS operating system is Ubuntu 14.04 x64 bit. Otherwise Virtualmin installation will fail. If you want to save all the trouble going through this tutorial, you can hire me to do it for you.
[product_slider category=”installations” orderby=”date” order=”desc” latest=”1″ style=”traditional”]

So let’s start by removing some packages that might have already installed on the server with OS.

apt-get purge apache2* bind9* samba*

Your server’s hostname should be a fully qualified domain name (Such as example.com or sub.example.com) for Virtualmin to work. You can check your current hostname by running following command.

hostname -f

That should output your current hostname. If it’s something other than your domain or a sub-domain, you should fix it before going any further. you can do it by following ‘Change Ubuntu 14.04 Hostname from Command-line‘ tutorial.

Installing Virtualmin

Assuming you have a proper hostname setup for your server, let’s download Virtualmin install script,

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

Run the script you just downloaded with,

sh /root/install.sh

Installation process will take few minutes to complete. The script will install Apache2 as http server by default. Since we’re going to use Nginx, we should stop Apache2.

service apache2 stop

Now it’s safe to install Nginx,

apt-get install nginx

Following command will add two plugins to Virtualmin that enable Nginx support,

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

Installing PHP 5 modules

You’ll need some PHP 5 modules installed on your server to host php applications error free. So lets install the lot,

apt-get install memcached mcrypt php5-memcache php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php-pear php5-dev php5-imap php5-mcrypt

And enable the php5-mcrypt module,

php5enmod mcrypt

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.

https://example.com:10000/

After successful login, you’ll be taken to the Virtualmin Post-Installation Wizard. 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

Although Virtualmin is successfully installed and Apache2 web server has been stopped, Virtualmin is still configured use to Apache2. To change that please go to System Settings -> Features and Plugins from your Virtualmin dashboard and disable (un-check) following features.

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

And enable following,

  • Nginx website
  • Nginx SSL website

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. Then check nginx and click Start On Boot. That’ll make sure Nginx is started with system reboots. Your Virtualmin should be ready to host websites with Nginx as the web server at this point. More on that later.

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, contact me here.

7 Comments

  1. Nice post but i am stuck at the following line:
    sudo apt-get install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl
    It gives me following error:
    root@trackingstats:~# sudo apt-get install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package webmin-virtualmin-nginx
    E: Unable to locate package webmin-virtualmin-nginx-ssl
    root@trackingstats:~# sudo service apache2 stop
    * Stopping web server apache2 *
    root@trackingstats:~# sudo apt-get install nginx
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    nginx is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 25 not upgraded.
    root@trackingstats:~# sudo apt-get install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package webmin-virtualmin-nginx
    E: Unable to locate package webmin-virtualmin-nginx-ssl
    root@trackingstats:~#

    Can you help??

  2. Hello Bro,
    I started from a fresh droplet in Digital ocean and successfully installed Virtualmin and Ngnix.I also created a new virtual server and consequently uploaded prosper202 files in public_html folder that was created during creation of virtualserver.Also changed DNS servers with the registrar and added the domain in Digital ocean droplet.However when i type the domain name, it gives me that default message “Ngnix is working fine”.It doesn’t take me to the prosper configuration page.I input Database information manually in 202-config.php file and uploaded it back to the public_html folder,however i am not sure why it is not working.Kindly tell me what can be the issue.
    Here are some screenshots.
    http://i66.tinypic.com/5ttcad.png (Virtual Sever Dashboard)
    http://i64.tinypic.com/9gezxz.png (FTP Client)
    http://i68.tinypic.com/j0up36.png (Message Displayed on loading the website)

    1. You don’t have to create Nginx configuration file. It’s there already. In Virtualmin, go to System Settings > Re-Check Configuration and check what’s wrong with your server.

Leave a Reply

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

Back to top button

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.