This short tutorial is based on this original article at Virtualmin wiki with a few tweaks to enable us to run the latest stable version of Nginx software in Virtualmin.
Over the short few years since Nginx was first introduced, it has grown by leaps and bounds in popularity and it is currently being used by 40% of the world’s busiest websites. It is fast, stable and uses less resources compared to the Apache webserver. But we will not go into the Apache vs Nginx here …
But before you install Nginx, please be aware of the following:
- If you currently have a Virtual Server running on Apache, you can’t install Nginx because Virtualmin will only allow you to run either Apache or Nginx. You can’t run both on port 80.
- Once you’ve installed Nginx, you will need to disable Apache from the Virtualmin’s Plugin & Features page.
- Virtualmin (at this point in time) does not support Nginx as Reverse-Proxy. If you are interested in this topic (running Nginx as reverse proxy to Apache), let me know and I’ll put up a tutorial on it later.
You can install Nginx from Virtualmin’s software repository which provides an older version of the Nginx software (version 1.0.9 as of this writing – 23 Oct 2014). Most software repositories such as the CentOS repo, EPEL, Ubuntu, etc do not carry the latest version. But if you want to install the latest stable version, you need to go to the source directly and install the Nginx repository.
Goto: http://nginx.org/en/linux_packages.html#stable and download the version for your Operating System.
In our case, we will base this tutorial on CentOS 6.5.
Step 1: Download the Nginx repo and install it. Then run the ‘yum’ command to install Nginx
wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
rpm -ivh nginx-release-rhel6*
yum install nginx -y
Step 2: Shutdown the Apache webserver & start the Nginx webserver
/sbin/service httpd stop && chkconfig httpd off
/sbin/service nginx start
Step 3: Install the Virtualmin’s Nginx plugin
yum install wbm-virtualmin-nginx wbm-virtualmin-nginx-ssl
Step 4: Login to Virtualmin and go to “System Setings” –> “Plugin & Features”
Disable the following:
- Apache Webserver
- SSL Website
- DAV login
- Webalizer Reporting
- AWstats Reporting
- Mailman
- Protected Directories
- Subversion repositories
Enable the following:
- Nginx Website
- Nginx SSL website
See the screenshot of the Virtualmin’s “Plugin and Features” page:
Once you’ve done this, Nginx support has been enabled in Virtualmin and you should be able to create Virtual Servers as normal.
However, do take note that when using Nginx instead of the Apache webserver, there are some limitations to consider:
- Nginx does not support CGI, so any applications or Virtualmin scripts that use CGI will not work.
- PHP can only be executed via FastCGI, and all PHP scripts run with domain owner permissions. Virtualmin will setup a PHP FastCGI server process that communicates with Nginx for each virtual server. mod_php is not supported.
- Only one PHP version (usually the highest) will be used by Nginx.
- You can only install one SSL certificate per IP address on your virtual server – even if you have a wildcard or UCC certificate. To install additional certificates, you would need to have additional IP addresses.
Great tutorial….Please write a tutorial to run Nginx as reverse proxy to Apache on Virtualmin. I am going to use centos 6.5 o 7.
Hi Kayina,
Thanks for your kind words! I’ve written (in-depth) on how to run Nginx as reverse proxy to Apache on Virtualmin in my “Virtualmin Tips and Hacks” book – sold on Amazon Kindle. The link to the book is on the sidebar. Check it out.
Best regards,
Adrian
hi there,
i bought it but i cant download the source files…there is a 500 error on the page.
Already email you.
just a question..can i Install the Virtualmin’s Nginx plugin and run together? its not mention about this..
got few questions like SSL to be handle by nginx/apache if so ports to be change etc,
For a fresh install to be followed..steps 1 virtualmin to be install first?
Hi Kayina,
I’ve replied your email. The Virtualmin’s Nginx plugin assumes that you want to use Nginx as the primary web-server and not Apache. When using the Nginx plugin in Virtualmin, you cannot run Apache (you’ll have to choose either Nginx or Apache).
If you want to run Nginx as reverse-proxy, then you need to install it manually – which is quite easy as well.
SSL would be installed in Apache since it’s the primary webserver.
Best regards,
Adrian