Welcome to UltratechHost Forum, Guest. Please take the time to register if you haven't, or click

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

[-]
Tags
how to enable varnish in cpanel server

cPanel/WHM How to enable Varnish in cPanel server
#1
Varnish is a caching technology. Varnish is a web accelerator and also referred as HTTP accelerator or reverse HTTP proxy, which will significantly enhance the performance of your website. Varnish cache is really fast thereby, speed up the delivery depending on your architecture.

Varnish enhance your website’s performance. 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 needs to handle only less traffic and there by increase the website performance and also reduce the server load.

Working of Varnish Cache
Once Varnish is installed in your server, it will listen in the port 80. Make Apache to listen in any other port other than 80. When a client requests for a page in your website, Varnish will try to serve the page from its cache memory. This is cache hit. If the page is not in its cache memory, then Varnish will request to HTTP (Apache) to serve the page and caches it for future reference.
Features of Varnish
1. Reduces the server load
2. High speed (cache + stored in RAM)
3. Useful to gain more visitors
Installation
1. Make Apache listen in any other port other than 80. Here I am making Apache to listen in port 8080. It can be done in two ways. Either editing the httpd.conf file or editing the Tweak settings in WHM
a) Editing httpd.conf file


Code:
vi /usr/local/apache/conf/httpd.conf

Locate the following line in /usr/local/apache/conf/httpd.conf file and change the port from 80 to 8080

Code:
Listen 0.0.0.0:80

Once edited, the Apache config file for “Listen” should be as follows:


Code:
grep -iw listen /usr/local/apache/conf/httpd.conf
Listen 0.0.0.0:8080

OR

b) Editing WHM – Tweak settings

Code:
WHM > Tweak Settings > Apache non-SSL IP/port

Install Varnish repository

Download and install the varnish repository depending on your architecture. For CentOS 6 and CentOS7.

For me, it was CentOS 6.

Code:
http://repo.varnish-cache.org/redhat/varnish-4.0/el6/noarch/varnish-release/varnish-release-4.0-4.el6.noarch.rpm
rpm -Uvh varnish-release-4.0-4.el6.noarch.rpm

Install Varnish

Code:
yum install varnish

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


Code:
grep VARNISH_LISTEN_PORT /etc/sysconfig/varnish
VARNISH_LISTEN_PORT=80

Edit Varnish config: /etc/varnish/default.vcl . Correct the IP address in this file to your IP address and port to 80


Code:
backend default {
 .host = "YOUR IP ADDRESS";
 .port = "80";
}

Start Varnish service on your server

Code:
chkconfig varnish on
service varnish start

You can check this by using the netstat command.

Code:
netstat -plan | grep :80



Dinesh Kumar Mohanty
Ultra Web Solutions®
Bhubaneswar, Odisha, India.

UltratechHost - Your One Stop Offshore & Onshore Hosting Provider
Server Locations : Netherlands, Germany, Russia, Singapore & USA
Service Offers: Shared hosting | Reseller hosting | Cloud server | Dedicated server | VPS Hosting



Forum Jump:


Users browsing this thread: 1 Guest(s)