{"id":2185,"date":"2016-07-06T13:29:43","date_gmt":"2016-07-06T17:29:43","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2185"},"modified":"2016-09-30T13:50:46","modified_gmt":"2016-09-30T17:50:46","slug":"setup-varnish-ubuntu-14","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/","title":{"rendered":"How to Setup Varnish on Ubuntu 14"},"content":{"rendered":"<p>Varnish is a fast, efficient HTTP caching layer that sits between browsers and a web application. Perhaps the process of generating a page is time-consuming and resource-intensive, despite the fact that the page changes infrequently. Or perhaps a page and its assets transfer slowly between geographically disparate sites, but are served much more quickly within specific regions. With Varnish cache in place between a site and its viewers, a variety of caching scenarios can be accounted for. Using an HTTP cache like Varnish is one of many strategies that can be used to speed up a website.<\/p>\n<h2>Getting Started<\/h2>\n<p>To complete this guide, you will need the following:<br \/>\n\u2022 1 Node (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) running Ubuntu 14.<br \/>\n\u2022 A LAMP stack configured<br \/>\n\u2022 Root Access to your server<\/p>\n<p>When finished, your Apache assets will be fronted by a Varnish cache.<\/p>\n<h2>Tutorial<\/h2>\n<p>Begin by installing the Varnish package itself.<\/p>\n<p><code>apt-get install varnish -y<\/code><\/p>\n<p>Varnish won&#8217;t do much unless it is configured. We&#8217;ll next configure various Varnish options to integrate it with the installed LAMP stack.<\/p>\n<p><code>nano \/etc\/default\/varnish<\/code><\/p>\n<p>Find the Alternative 2 section. Once there, change:<\/p>\n<p><code class=\"gris\">DAEMON_OPTS=\"-a :6081 \\<\/code><\/p>\n<p>to the following:<\/p>\n<p><code class=\"gris\">DAEMON_OPTS=\"-a :80 \\<\/code><\/p>\n<p>We must now configure the Varnish VCL.<\/p>\n<p><code>nano \/etc\/varnish\/default.vcl<\/code><\/p>\n<p><code class=\"gris\">backend default {<br \/>\n    .host = \"127.0.0.1\";<br \/>\n    .port = \"8080\";<br \/>\n}<\/code><\/p>\n<p>Varnish&#8217;s default port is 8080. If you use this, you&#8217;ll need to update your Apache configuration separately as shown in the next section.<\/p>\n<p>Apache&#8217;s default port must be set to match the port as configured in the Varnish VCL above.<\/p>\n<p><code>nano \/etc\/apache2\/ports.conf<\/code><\/p>\n<p><code class=\"gris\">Listen 80<\/code><\/p>\n<p>Set it to:<\/p>\n<p><code class=\"gris\">Listen 8080<\/code><\/p>\n<p>In order for your new configuration to take effect, both Apache and Varnish must be restarted. We&#8217;ll do that now.<\/p>\n<p><code>service apache2 restart<br \/>\nservice varnish restart<\/code><\/p>\n<p>To determine if Varnish is caching, let&#8217;s look at its statistics.<\/p>\n<p><code>varnishstat<\/code><\/p>\n<p>We&#8217;ll further confirm that things are working by ensuring that Varnish and Apache are communicating correctly.<\/p>\n<p><code>curl -I http:\/\/your_ip <---------------- Change for your main IP<\/code><\/p>\n<p><code class=\"gris\">HTTP\/1.1 200 OK<br \/>\nServer: Apache\/2.4.7 (Ubuntu)<br \/>\nVary: Accept-Encoding<br \/>\nContent-Type: text\/html;charset=UTF-8<br \/>\nDate: Tue, 21 Jun 2016 10:59:29 GMT<br \/>\nX-Varnish: 1661719520<br \/>\nAge: 0<br \/>\nVia: 1.1 varnish<br \/>\nConnection: keep-alive<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>Apache is now fronted by Varnish. If PHP is slow at generating a page but its content rarely changes, the slowness will only manifest itself on first access or cache invalidation. Future loads will be significantly faster, and load on the server will lessen as PHP is no longer relied upon for every single site access. If this guide was helpful to you, kindly share it with others who may also be interested. <\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Varnish is a fast, efficient HTTP caching layer that sits between browsers and a web application. Perhaps the process of generating a page is time-consuming and resource-intensive, despite the fact that the page changes infrequently. Or perhaps a page and its assets transfer slowly between geographically disparate sites, but are served much more quickly within<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-2185","post","type-post","status-publish","format-standard","hentry","category-web-hosting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Setup Varnish on Ubuntu 14 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will walk you through the setup of Varnish cache on your Ubuntu 14 server. Read now &amp; Enjoy your new HTTP caching layer!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Setup Varnish on Ubuntu 14 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will walk you through the setup of Varnish cache on your Ubuntu 14 server. Read now &amp; Enjoy your new HTTP caching layer!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-06T17:29:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-09-30T17:50:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/\"},\"author\":{\"name\":\"GloboTech Communications\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"headline\":\"How to Setup Varnish on Ubuntu 14\",\"datePublished\":\"2016-07-06T17:29:43+00:00\",\"dateModified\":\"2016-09-30T17:50:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/\"},\"wordCount\":361,\"commentCount\":0,\"articleSection\":[\"Web Hosting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/\",\"url\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/\",\"name\":\"How to Setup Varnish on Ubuntu 14 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#website\"},\"datePublished\":\"2016-07-06T17:29:43+00:00\",\"dateModified\":\"2016-09-30T17:50:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will walk you through the setup of Varnish cache on your Ubuntu 14 server. Read now & Enjoy your new HTTP caching layer!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-varnish-ubuntu-14\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Setup Varnish on Ubuntu 14\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#website\",\"url\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\\\/\\\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Setup Varnish on Ubuntu 14 - Globo.Tech","description":"This tutorial will walk you through the setup of Varnish cache on your Ubuntu 14 server. Read now & Enjoy your new HTTP caching layer!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/","og_locale":"en_US","og_type":"article","og_title":"How to Setup Varnish on Ubuntu 14 - Globo.Tech","og_description":"This tutorial will walk you through the setup of Varnish cache on your Ubuntu 14 server. Read now & Enjoy your new HTTP caching layer!","og_url":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/","og_site_name":"Globo.Tech","article_published_time":"2016-07-06T17:29:43+00:00","article_modified_time":"2016-09-30T17:50:46+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/#article","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/"},"author":{"name":"GloboTech Communications","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"headline":"How to Setup Varnish on Ubuntu 14","datePublished":"2016-07-06T17:29:43+00:00","dateModified":"2016-09-30T17:50:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/"},"wordCount":361,"commentCount":0,"articleSection":["Web Hosting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/","url":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/","name":"How to Setup Varnish on Ubuntu 14 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-07-06T17:29:43+00:00","dateModified":"2016-09-30T17:50:46+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will walk you through the setup of Varnish cache on your Ubuntu 14 server. Read now & Enjoy your new HTTP caching layer!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/setup-varnish-ubuntu-14\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to Setup Varnish on Ubuntu 14"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2185"}],"version-history":[{"count":3,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2185\/revisions"}],"predecessor-version":[{"id":2891,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2185\/revisions\/2891"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}