{"id":3613,"date":"2017-11-02T13:34:13","date_gmt":"2017-11-02T17:34:13","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=3613"},"modified":"2017-11-02T13:34:13","modified_gmt":"2017-11-02T17:34:13","slug":"install-configure-varnish-cache-apache-d9","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/","title":{"rendered":"Install &#038; Configure Varnish Cache with Apache on Debian 9"},"content":{"rendered":"<h1>Install &amp; Configure Varnish Cache with Apache on Debian 9<\/h1>\n<div class=\"row\">\n<div class=\"col-lg-8\">\n<p><a rel=\"nofollow\" href=\"https:\/\/varnish-cache.org\/\">Varnish Cache<\/a> is an often used but not commonly known accelerator designed specifically for use with Hypertext Transfer Protocol, known by the abbreviation HTTP. As an HTTP accelerator, Varnish Cache works by taking information or data, storing it in a virtual memory cache, and then allowing the operating system to decide if information needs to be moved to more traditional storage. This alleviates the condition where the operating system continues to try and store tons of data on the disk itself. In practical use, Varnish Cache helps load web pages quicker when requested by a user.<\/p>\n<\/div>\n<div class=\"col-lg-4\">\n<img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"117\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/10\/varnish_cache_RGB_medium.png\" alt=\"configure varnish cache\" class=\"alignright size-full wp-image-3619\" \/>\n<\/div>\n<\/div>\n<p>Varnish Cache is open-source, meaning the software belongs to a family of free software licenses, allowing use and distribution with minimal restriction.<\/p>\n<h2>Getting Started<\/h2>\n<p>To install and configure Varnish Cache, a node with an updated Linux Debian 9 installation is required. Debian 9, sometimes called Debian Stretch, is a specific Linux-based operating system we&#8217;re using for this installation. Additionally, the node you choose may be <strong><a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\">cloud-based<\/a><\/strong>, or it can be hosted on a <strong><a href=\"https:\/\/www.globo.tech\/dedicated-server-hosting\">dedicated server<\/a><\/strong>.<\/p>\n<h2>Install and Configure Varnish Cache with Apache on Debian 9<\/h2>\n<p>Now that you&#8217;re chosen your node and have confirmed your node has Linux Debian 9 installed, we can setup Varnish Cache and Apache.<\/p>\n<p><strong>Installing Apache<\/strong><\/p>\n<p>Before we can install and configure Varnish Cache, we need to install Apache on your node. The first step in that process is updating the Apache package and the operating system:<br \/>\n<code>apt update<br \/>\napt upgrade <\/code><\/p>\n<p>After the package is downloaded and the operating system is updated, install Apache 2.4:<br \/>\n<code>apt -y install apache2 <\/code><\/p>\n<p>When the installation completes, it&#8217;s time to start and enable the Apache service:<br \/>\n<code>systemctl enable apache2 &amp;&amp; systemctl start apache2 <\/code><\/p>\n<p>If you have UFW enabled, you can utilize the commands below. If you do not have UFW enabled, skip the commands below:<br \/>\n<code>ufw allow 80\/tcp<br \/>\nufw allow 443\/tcp<br \/>\nufw reload <\/code><\/p>\n<p><strong>Installing and Configuring Varnish Cache<\/strong><\/p>\n<p>With the Apache installation complete, it&#8217;s time to move onto Varnish Cache.<\/p>\n<p>The first step is to download the GPG key and then add it:<br \/>\n<code>curl -L https:\/\/packagecloud.io\/varnishcache\/varnish5\/gpgkey | sudo apt-key add - <\/code><\/p>\n<p>Next, the package repository requirements need to be installed:<br \/>\n<code>apt install -y debian-archive-keyring apt-transport-https <\/code><\/p>\n<p>Once complete, the repository needs to be added to the source list:<br \/>\n<code>echo \"deb https:\/\/packagecloud.io\/varnishcache\/varnish5\/debian\/ stretch main\" &gt; \/etc\/apt\/sources.list.d\/varnishcache5.list <\/code><\/p>\n<p>The package manager will also need to be updated so that the new repository can be added:<br \/>\n<code>apt update<\/code><\/p>\n<p>Now that the repository has been installed and the necessary components are updated, Varnish Cache may be installed:<br \/>\n<code>apt install -y varnish <\/code><\/p>\n<p>With any installation, once complete, it&#8217;s important to check that the installed version matches what you anticipated. Check that Varnish Cache is installed and the proper version was installed:<br \/>\n<code>varnishd -V <\/code><\/p>\n<p>After confirming your installation, we can configure Varnish Cache to listen to port 80 by editing the following file, replacing port 6081 by port 80:<br \/>\n<code>nano \/lib\/systemd\/system\/varnish.service<\/code><\/p>\n<p>From:<br \/>\n<code class=\"gris\">ExecStart=\/usr\/sbin\/varnishd -a :6081 -T localhost:6082 -f \/etc\/varnish\/default.vcl -S \/etc\/varnish\/secret -s malloc,256m<\/code><\/p>\n<p>To:<br \/>\n<code class=\"gris\">ExecStart=\/usr\/sbin\/varnishd -a :80 -T localhost:6082 -f \/etc\/varnish\/default.vcl -S \/etc\/varnish\/secret -s malloc,256m<\/code><\/p>\n<p>Once the file has been edited, we need to reload the system daemon to update the file:<br \/>\n<code>systemctl daemon-reload<\/code><\/p>\n<p>When the reload is complete, the default configuration needs to be modified, telling the system where to redirect the received Varnish Cache requests:<br \/>\n<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>Apache 2.4 will also need a slight modification, enabling it to listen on port 8080 instead of port 80:<br \/>\n<code>nano \/etc\/apache2\/ports.conf<\/code><br \/>\n<code class=\"gris\">Listen 8080<\/code><\/p>\n<p><code>nano \/etc\/apache2\/sites-enabled\/000-default.conf <\/code><br \/>\n<code class=\"gris\">&lt;VirtualHost *:8080&gt;<\/code><\/p>\n<p>Once the modification has been made, restart Apache 2.4 and Varnish Cache. When the restart completes, enable Varnish Cache:<br \/>\n<code>systemctl restart apache2<br \/>\nsystemctl restart varnish<br \/>\nsystemctl enable varnish <\/code><\/p>\n<p>Now it&#8217;s time to test Varnish Cache and Apache 2.4, ensuring both are functioning as expected:<br \/>\n<code>curl -I http:\/\/127.0.0.1<\/code><br \/>\n<code class=\"gris\">HTTP\/1.1 200 OK<br \/>\nServer: Apache\/2.4.25 (Debian)<br \/>\nVary: Accept-Encoding<br \/>\nContent-Type: text\/html<br \/>\nX-Varnish: 2<br \/>\nAge: 0<br \/>\nVia: 1.1 varnish (Varnish\/5.1)<br \/>\nETag: W\/\"29cd-55771150d08a7-gzip\"<br \/>\nAccept-Ranges: bytes<br \/>\nConnection: keep-alive <\/code><\/p>\n<p>If necessary, the Varnish Cache stats can be checked using the following command:<br \/>\n<code>varnishstat <\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>Congratulations, you&#8217;ve successfully installed Apache 2.4 and the installed and configured Varnish Cache on your Linux Debian 9 node. This installation allows you to streamline your web page distribution, allowing users to access information quicker and more efficiently than before. If you found this guide helpful during your setup, or if you know of anyone else attempting the same installation, please share this with them.<\/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>Install &amp; Configure Varnish Cache with Apache on Debian 9 Varnish Cache is an often used but not commonly known accelerator designed specifically for use with Hypertext Transfer Protocol, known by the abbreviation HTTP. As an HTTP accelerator, Varnish Cache works by taking information or data, storing it in a virtual memory cache, and then<!-- 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-3613","post","type-post","status-publish","format-standard","hentry","category-web-hosting","operating_system-debian"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Install &amp; Configure Varnish Cache with Apache on Debian 9 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"Before we can install and configure Varnish Cache, we need to install Apache on your node. The first step in that process is updating the Apache ...\" \/>\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\/install-configure-varnish-cache-apache-d9\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Install &amp; Configure Varnish Cache with Apache on Debian 9 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"Before we can install and configure Varnish Cache, we need to install Apache on your node. The first step in that process is updating the Apache ...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-02T17:34:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/10\/varnish_cache_RGB_medium.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=\"4 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\\\/install-configure-varnish-cache-apache-d9\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/\"},\"author\":{\"name\":\"GloboTech Communications\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"headline\":\"Install &#038; Configure Varnish Cache with Apache on Debian 9\",\"datePublished\":\"2017-11-02T17:34:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/\"},\"wordCount\":610,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/wp-content\\\/uploads\\\/2017\\\/10\\\/varnish_cache_RGB_medium.png\",\"articleSection\":[\"Web Hosting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/\",\"url\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/\",\"name\":\"Install & Configure Varnish Cache with Apache on Debian 9 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/wp-content\\\/uploads\\\/2017\\\/10\\\/varnish_cache_RGB_medium.png\",\"datePublished\":\"2017-11-02T17:34:13+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"Before we can install and configure Varnish Cache, we need to install Apache on your node. The first step in that process is updating the Apache ...\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/wp-content\\\/uploads\\\/2017\\\/10\\\/varnish_cache_RGB_medium.png\",\"contentUrl\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/wp-content\\\/uploads\\\/2017\\\/10\\\/varnish_cache_RGB_medium.png\",\"width\":320,\"height\":117,\"caption\":\"varnish_cache\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/install-configure-varnish-cache-apache-d9\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Install &#038; Configure Varnish Cache with Apache on Debian 9\"}]},{\"@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":"Install & Configure Varnish Cache with Apache on Debian 9 - Globo.Tech","description":"Before we can install and configure Varnish Cache, we need to install Apache on your node. The first step in that process is updating the Apache ...","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\/install-configure-varnish-cache-apache-d9\/","og_locale":"en_US","og_type":"article","og_title":"Install & Configure Varnish Cache with Apache on Debian 9 - Globo.Tech","og_description":"Before we can install and configure Varnish Cache, we need to install Apache on your node. The first step in that process is updating the Apache ...","og_url":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/","og_site_name":"Globo.Tech","article_published_time":"2017-11-02T17:34:13+00:00","og_image":[{"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/10\/varnish_cache_RGB_medium.png","type":"","width":"","height":""}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/#article","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/"},"author":{"name":"GloboTech Communications","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"headline":"Install &#038; Configure Varnish Cache with Apache on Debian 9","datePublished":"2017-11-02T17:34:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/"},"wordCount":610,"commentCount":0,"image":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/#primaryimage"},"thumbnailUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/10\/varnish_cache_RGB_medium.png","articleSection":["Web Hosting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/","url":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/","name":"Install & Configure Varnish Cache with Apache on Debian 9 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/#primaryimage"},"image":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/#primaryimage"},"thumbnailUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/10\/varnish_cache_RGB_medium.png","datePublished":"2017-11-02T17:34:13+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"Before we can install and configure Varnish Cache, we need to install Apache on your node. The first step in that process is updating the Apache ...","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/#primaryimage","url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/10\/varnish_cache_RGB_medium.png","contentUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2017\/10\/varnish_cache_RGB_medium.png","width":320,"height":117,"caption":"varnish_cache"},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-configure-varnish-cache-apache-d9\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"Install &#038; Configure Varnish Cache with Apache on Debian 9"}]},{"@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\/3613","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=3613"}],"version-history":[{"count":10,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3613\/revisions"}],"predecessor-version":[{"id":3637,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3613\/revisions\/3637"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=3613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=3613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=3613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}