Nginx is a very fast webserver when compared with the default Apache offered by cPanel. Nginx is known for its high performance and low resource consumption. Servers hosting WordPress sites are employing Nginx as it improves the performance.

Nginx will work as a front end reverse proxy of your cPanel server along with apache, which will increase the performance. We have a plugin called ‘Nginx Admin’ which is a cPanel Nginx integration plugin.

Use the following steps to install it on a cPanel server :

1 ) Download the source files :

# cd /usr/local/src
# wget http://nginxcp.com/latest/nginxadmin.tar
# tar xf nginxadmin.tar
# cd publicnginx

2) Generate a Remote Access Key.

Generate a key by logging into WHM, going to Clusters, then Remote Key Access, and then clicking Generate New Key.

3) Run the script

# ./nginxinstaller install

This Nginx installation method integrates with WHM/cPanel and uses the Apache configuration files that WHM/cPanel uses by default.

After installation you can go to WHM, Plugins, and Nginx Admin to handle Nginx. From there you can restart Nginx, edit the configuration files, view logs, and more.

You can also restart Nginx on the command line with the Apache command:

# /etc/init.d/httpd restart

Now lets move ahead with the installation of Varnish.

Varnish is a caching technology known as web accelerator which is used as reverse HTTP proxy, which will enhance the performance of your website.

Varnish stores a copy of the page which is served by the web server the first time a user visits the website. Next time, when the user requests for the same page, varnish will serve the copy instead of serving it from the web server. Thus, your webserver is seldom bought into the lime-light if the used pages are being fetched, which improves the performance.

Before moving ahead, we will bind our webserver to the port 8081, in the file – /usr/local/apache/conf/httpd.conf,

Change the Portion – Listen 0.0.0.0:80 to Listen 0.0.0.0:8081 and restart the webservice.

Now, lets download and install the Varnish !

1) Add the repo : ( check the version of your OS ) : the URL given below is for CentOS / Redhat 5.x versions :

# wget http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.noarch.rpm

# rpm -Uvh varnish-release-3.0-1.noarch.rpm

2) Install the service :

# yum install varnish

3) Edit the configuration file for varnish – /etc/sysconfig/varnish and change the value of VARNISH_LISTEN_PORT to 80

# grep VARNISH_LISTEN_PORT /etc/sysconfig/varnish
VARNISH_LISTEN_PORT=80
4)  Edit Varnish config: /etc/varnish/default.vcl . Correct the backend default Port to reflect – 8081 ( the port to which webserver was bind to )

backend default {
.host = “YOUR IP ADDRESS”;
.port = “8081”;
}

5) Start Varnish service on your server

# chkconfig varnish on

# service varnish start

You are done with installing Nginx and varnish in your cPanel server, which should improve your speed and performance.