Step 1: Turn off Apache

First, it's important to turn off the Apache webserver which is configured by default by Virtualmin. 

Run the following command to turn off Apache:

service httpd stop

Next, make it so that Apache isn't restarted automatically on the next boot by running the following command:

chkconfig httpd off

Those two commands will prevent Apache from running and from ever starting up automatically on boot. You can even uninstall Apache at this time if you wish, but it's not necessary.

How to set up Virtualmin to use Nginx webserver

Virtualmin supports Nginx webserver and has for a while now. In this lesson, I will show you how to set up Virtualmin to use Nginx webserver instead of Apache webserver.

Getting things ready

For this tutorial, make sure that you have a VPS or other server with Virtualmin installed. Information on how to install Virtualmin can be found here. It is easy to do using the Virtualmin install script.

I'm using a VPS with 768 MB of RAM, but as little as 256 MB should work to. I'm also using CentOS as an operating system, but Debian and Ubuntu also work well with Virtualmin and Nginx.

So before you proceed, make sure you have a VPS with a clean install of Virtualmin. It is important to only do this on a freshly installed Virtualmin server and not to do this on a server that already has websites configured in Virtualmin. So start fresh with a clean Virtualmin install.

Once you have Virtualmin installed and running, go ahead and proceed in setting up Nginx with the instructions that follow.

Step 2: Install Nginx

Install Nginx by executing the following command:

yum install nginx

Step 3: Start Nginx

Now start the nginx webserver with the following command:

service nginx start

Step 4: Install Nginx plugin for Virtualmin

Now install the Virtualmin Nginx plugin:

yum install wbm-virtualmin-nginx wbm-virtualmin-nginx-ssl

This installs both the regular nginx plugin and the ssl nginx plugin. It is not necessary to install both, but both are installed in this lesson.

Step 5: Verify the Nginx plugin install

Now log in to Webmin using a web browser as the root user. If you're already logged in to webmin, you will need to log out and log back in again. 

Verify that nginx features have been installed in Webmin by navigating to Webmin -> Servers -> Nginx Webserver. The presence of "Nginx Webserver" under the Servers section should be enough to verify that the Nginx Virtualmin plugin was installed.

Step 6: Disable all Apache-related Virtualmin features

Go to the "Features and Plugins" section of Virtualmin at  Virtualmin -> System Settings -> Features and Plugins.

Uncheck the boxes next to the following features:

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

Then click the "Save" button. 

In the event that Virtualmin reports that other features must be disabled, then disable those features too.

Step 7: Enable Nginx-related Virtualmin features

Go back to the "Features and Plugins" section of Virtualmin at  Virtualmin -> System Settings -> Features and Plugins.

Enable the following features:

  • Nginx website
  • Nginx SSL website

Click the "Save" button.

 

Step 8: Verify that Nginx is properly configured with Virtualmin

You can verify that the Nginx plugin is setup by going to the main page of Virtualmin and then clicking the refresh button, which in recent versions of Virtualmin appears as only a green colored icon at the top right of the page. 

Then scroll to the bottom of the page and expand the "Status" section and you should see "Nginx Webserver" listed among the services there. It should indicate that Nginx is running. Clicking the "Nginx Webserver" text will lead you to a page where you can view and modify the Nginx Webserver configuration.

Step 9: Create a virtual server with Nginx

Everything is set up properly and you can now create a virtual server using Virtualmin and Nginx. It's very straightforward. 

  1. From Virtualmin, click the "Create Virtual Server" link.
  2. Enter the domain name you wish to use, the administration password, and any of the other optional information.
  3. Click the "Create Server" button.

That's it. Virtualmin will do the rest, including setting up the Nginx virtual server, along with setting up the other features such as mysql, mail, SSL, etc.

That's the end

This tutorial walked you through disabling the Apache webserver that is normally configured on a basic Virtualmin install. And then you installed nginx and the nginx plugin for Virtualmin. 

Virtualmin is now able to create virtual servers using Nginx just as it would with Apache.

All virtual servers that you create will be fully configured to use Nginx.