If you need the latest version of Varnish, you’ll have to manually compile it yourself and install it. this post shows students and new users how to manually compile and install Varnish cache 6.0 which is the latest at the time of this post on Ubuntu 16.04 | 18.04 LTS servers. For this post, we’ll install the Apache2 web server and configure it to listen on port 8080. then install Varnish and configure it to listen on port 80. Varnish will cache all requests for Apache2 pages when they are made. To get this working, please follow the steps below:

Install Apache2 HTTP Server

To install Apache2 on Ubuntu run the commands below. After installing Apache2, the commands below can be used to stop, start and enable Apache2 to always startup every time the server boots up. By default apache2 HTTP service automatically is bound to ports 80 and 443 for HTTPS.  We want Varnish to communicate over port 80 instead. So continue below to configure Apache2 to talk on Port 8080. To quickly change the port run the commands below to open the Apache2 default port configuration file. Then make sure the file has these lines. Save when done. Next, open the Apache2 default virtual host config file. Then make the highlighted change below. Save the file and exit. Then restart Apache2 Now to access Apache2, you’ll have to enter the server IP or hostname followed by port # 8080. ex. http://localhost:8080

Installing Varnish 6.0

Now that Apache2 is installed and communicating over port 8080, follow the steps below to install the latest version of Varnish. First, install all dependencies for Varnish by running the commands below. Next, run the commands below to download the Varnish package. After that, change into a varnish-cache folder and begin compiling. Next, run the commands below to install the Varnish cache. It should take a few minutes for it to install. after that Varnish will now be installed in /usr/local. The varnishd binary is in /usr/local/sbin/varnishd. To make sure that the necessary links and caches of the most recent shared libraries are found, run If Varnish was successfully installed, run the commands below to start it. That should do it. to test, run the commands below. and you should see something like the text below: Enjoy!