Varnish can be a good solution for a faster Apache, Nginx server. It will act like a cache and proxy in your server once installed. Can be a good option for high load server with lot of traffic.

First install the epel respository in your Centos 7 server since it is part of non-standart packages.

yum install -y epel-release

Update the Centos system with thw following command:

yum -y update

Install varnish

yum -y install varnish

Configure Varnish to run at server start up

systemctl enable varnish

Start Varnish

systemctl start varnish

In order to be sure the service started successfully please type the following command

systemctl status varnish

Check the Varnish version installed in your server

varnishd -V

After checked successfully please check the following file for the basic configuration

nano /etc/varnish/default.vcl

Edit the following lines into default.vcl

change VARNISH_LISTEN_POR to 80

Change the following lines as followed

backend default {
.host = "127.0.0.1";
.port = "8080";
}

change the apache configuration as well to work with Varnish

nano /etc/httpd/conf/httpd.conf

Change listen port from 80 to 8080

Listen 8080

Restart Apache and Varnish

sudo apachectl restart
systemctl restart varnish

If you will open your ip from the browser and check the apache log after you will see logs like this:

HTTP/1.1 200 OK
Date: Wed, 04 Nov 2015 10:21:07 GMT
Server: Apache/2.4.6 (CentOS)
Last-Modified: Fri, 02 Oct 2015 10:36:53 GMT
ETag: "6c-5211cdbf61c14"
Content-Length: 108
Content-Type: text/html; charset=UTF-8
X-Varnish: 32770
Age: 0
Via: 1.1 varnish-v4
Connection: keep-alive

 

 

Leave a Reply

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