{"id":171,"date":"2018-04-03T04:31:54","date_gmt":"2018-04-03T04:31:54","guid":{"rendered":"http:\/\/eliteservermanagement.com\/issues\/?p=171"},"modified":"2018-04-03T04:31:54","modified_gmt":"2018-04-03T04:31:54","slug":"how-to-install-and-configure-varnish","status":"publish","type":"post","link":"https:\/\/eliteservermanagement.com\/issues\/how-to-install-and-configure-varnish\/","title":{"rendered":"How to Install And Configure Varnish"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>How to Install And Configure Varnish<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Before installing Varnish, you will have to install the EPEL repository. You can do this by running the following command:<\/p>\n<p>yum install -y epel-release<br \/>\nyum install -y varnish<br \/>\nsystemctl start varnish<br \/>\nsystemctl enable varnish<br \/>\nsystemctl status varnish<br \/>\nvarnishd -V<\/p>\n<p><strong>Configure Varnish<\/strong><\/p>\n<p>The Varnish configuration file will be located in the \/etc\/varnish directory in CentOS 7. To make Varnish work in front of Apache, you will need to set up some basic configurations.<\/p>\n<p>By default Varnish listens on port 6081. You will need to change port 6081 to 80 so that website requests access the Varnish cache first. You can do this by editing the varnish.params config file.<\/p>\n<p>sudo nano \/etc\/varnish\/varnish.params<\/p>\n<p>Change VARNISH_LISTEN_PORT from 6081 to 80:<\/p>\n<p>VARNISH_LISTEN_PORT=80<br \/>\nSave the file, then open the default.vcl file. This file tells varnish to look for the server content:<\/p>\n<p>sudo nano \/etc\/varnish\/default.vcl<\/p>\n<p>Tell Varnish to get the content on port 8080.<\/p>\n<p>backend default {<br \/>\n.host = &#8220;127.0.0.1&#8221;;(Here replace 127.0.0.1 with server IP)<br \/>\n.port = &#8220;8080&#8221;;<br \/>\n}<\/p>\n<p><strong>Configure Litespeed to work with Varnish<\/strong><\/p>\n<p>Go to Home \u00bb Plugins \u00bb LiteSpeed Web Server Plugin &gt;&gt; Change LiteSpeed Port Offset &gt;&gt; 8000, litespeed will listen om port 8080<\/p>\n<p>Note:- Port offset allows you to run Apache and LiteSpeed in parallel by running LiteSpeed on a separate port.<br \/>\nFor example, if Apache is running on port 80 and the LiteSpeed port offset is 2000, then you will be able to access LiteSpeed-powered web pages on port 2080.<\/p>\n<p>Restart varnish and litespeed service<\/p>\n<p>Test Varnish<\/p>\n<p>curl -I http:\/\/localhost<br \/>\nHTTP\/1.1 200 OK<br \/>\nLast-Modified: Tue, 30 Aug 2016 17:01:17 GMT<br \/>\nContent-Type: text\/html<br \/>\nContent-Length: 111<br \/>\nDate: Tue, 03 Jan 2017 07:42:10 GMT<br \/>\nServer: LiteSpeed<br \/>\nX-Varnish: 7<br \/>\nAge: 0<br \/>\nVia: 1.1 varnish-v4<br \/>\nConnection: keep-alive<\/p>\n<p><b>eLite Server Management<br \/>\n<\/b>\u00a0We Specialize In cPanel Server Management<br \/>\nAffordable 24\/7 Technical Support Company<br \/>\n<a href=\"http:\/\/eliteservermanagement.com\/managed-dedicated-server\/\">Manage Dedicated Servers<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Install And Configure Varnish &nbsp; Before installing Varnish, you will have to install the EPEL repository. You can do this by running the following command: yum install -y epel-release yum install -y varnish systemctl start varnish systemctl enable varnish systemctl status varnish varnishd -V Configure Varnish The Varnish configuration file will be located [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/posts\/171"}],"collection":[{"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/comments?post=171"}],"version-history":[{"count":1,"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":172,"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/posts\/171\/revisions\/172"}],"wp:attachment":[{"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/media?parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/categories?post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eliteservermanagement.com\/issues\/wp-json\/wp\/v2\/tags?post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}