How to install and configure Varnish with apache on CentOS 7 step by step guide


In this article we learn what is varnish and how to install and configure Varnish 4 with apache and nginx on centos 7.

What is Varnish

Varnish is open source http reverse proxy, http accelerator and useful web caching tool which is place in front of apache web server to boost up the website. Varnish improves the performance of the web site by booting up the speed of the website.

Installation of Varnish on CentOS 7

By default there is no Varnish package available into the centos repository. To install Varnish we need to install EPEL repository. To install EPEL repo we execute the below command.

[root@localhost ~]#yum install -y epel-release

After installing the EPEL we execute the below command to install the Varnish package.

[root@localhost ~]#yum install -y varnish

After installed the varnish package we need to start the varnish service and enable the service on startup mode to execute the below command.

[root@localhost ~]#systemctl start varnish
[root@localhost ~]#systemctl enable varnish

After started the service we know the status using the below command.

[root@localhost ~]#systemctl status varnish
To check the version of varnish which is running on the server to execute the below command.
[root@localhost ~]#varnishd –V

How to install and configure Varnish with apache on CentOS 7 step by step guide

                    How to install and configure Varnish with apache on CentOS 7 step by step guide



Configuration of varnish on CentOS 7

Varnish configuration file is located at /etc/varnish. To configure varnish as a caching server which is placed in front of apache server first we need to edit “varnish.params” config file and change the listening port parameter value .By default it runs on 6081 we change it to port no 80 so that user can hit the caching server first to get the web page.

vi /etc/varnish/varnish.params

Change VARNISH_LISTEN_PORT from 6081 to 80.
VARNISH_LISTEN_PORT=80
Now open the “/etc/varnish/default.vcl” file and put the backaend web server details which is running 7001 port.
# Default backend definition. Set this to point to your content server.
backend default {
    .host = "127.0.0.1";
    .port = "7001";
}

 To install apache server on centos follow the below link.

To verify varnish is successfully configured or not we execute the below command.
[root@localhost ~]# curl -I http://localhost
HTTP/1.1 403 Forbidden
Date: Fri, 04 Jan 2019 15:03:06 GMT
Server: Apache/2.4.6 (CentOS)
Last-Modified: Thu, 16 Oct 2014 13:20:58 GMT
ETag: "1321-5058a1e728280"
Accept-Ranges: bytes
Content-Length: 4897
Content-Type: text/html; charset=UTF-8
X-Varnish: 2
Age: 0
Via: 1.1 varnish-v4
Connection: keep-alive

That’s all .We have configured Varnish .If this article is helpful to know about install and configre varnish with apache and nginx please share it!!!


 





SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment