Install Varnish Cache 4 and Varnish-Agent 4 on Mac OS

As a recent convert to the allure of Mac OS, Marius Magureanu, Software Developer at Varnish Software has become an active user. To test out his new playground he set himself on trying an out of the box (github) installation of Varnish Cache 4 and Varnish Agent on both his Mac Mini and Macbook Pro. Although one is less likely to find a real world production server scenario for Mac OS you’ll find below a guideline that will get Varnish Cache up and running on your Mac.

This tutorial is available for Mavericks and Yosemite. While unsure about earlier versions Mac OS, if what Apple claims in regards to their update adoption among users is true, then it’s likely you’re using the latest versions anyway.

Prerequisites

The following are prerequisites before building and installing either Varnish Cache4 and Varnish-Agent4. The assumption is that you will install Varnish Cache and the Varnish-Agent directly from the source code, thus make sure you clone from GitHub the 4.0 branch for both components.

Install brew (while installing brew you will be prompted to install Xcode command line tools as well):
-ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Install autoconf:
-brew install autoconf

Install python:
-brew install python

Install python docutils (required by rst2man):
-pip install docutils

Install pcre (perl compatible regex):
-brew install pcre

Install pkg-config:
-brew install pkg-config

Install libmicrohttpd:
-brew install libmicrohttpd

Install libtool:
-brew install libtool

Compilation and installation

After having the above installed, issue the following in your Varnish Cache 4 folder:

./autogen.sh
./configure
make
make install (may require sudo)

While installation, depending on your shell locale settings rst2man may throw the following error: ValueError: unknown locale: UTF-8 in Python.
Setting the variables below will get this error fixed:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
For convenience purposes you could just add the above to your ~/.bash_profile. Do a source ~/.bash_profile afterwards.

If VC4 has compiled successfully, move further to your Varnish-Agent folder and issue the following commands:
./autogen.sh
./configure
make
make install (may require sudo)

Start Varnish and Varnish-Agent

Since varnishd is a deamon and usually meant to be started automatically, it could be that it will get placed into /usr/local/sbin folder. This folder should not be part of your PATH, therefore issue this small command to move varnishd:

sudo mv /usr/local/sbin/varnishd /usr/local/bin/

By default varnish will create its working directory here: /usr/local/var/varnish/working_varnish_folder
Make sure “working_varnish_folder” has read/write permissions for the user under which Varnish will start.

To quickly setup a backend for your varnish, open another shell and issue the following command:
python -m SimpleHTTPServer

If no error has occurred during compilation and installation, try to start varnish and varnish-agent as follows:
sudo varnishd -a :80 -b 0.0.0.0:8000
sudo varnish-agent -u user -d

What’s next?

On the next episode of installations from Marius, we’ll explore ‘The Pi, the Arch and… the Varnish Cache’.

For any further assistance on your Mac OS installation, feel free to contact Marius at Varnish Software:marius@varnish-software.com

Interested in learning more from the masters?

While Paris and Frankfurt reached capacity, there’s still opportunity to join a Varnish Summit in Stockholm or San Francisco. The Varnish Summit series offer every opportunity for you to learn from the masters. Register now for your free pass, valued at €/$150.

Topics: Varnish Cache

28/10/14 14:00 by Marius Magureanu

All things Varnish related

The Varnish blog is where the our team writes about all things related to Varnish Cache and Varnish Software...or simply vents.

SUBSCRIBE TO OUR BLOG

Recent Posts

Posts by Topic

see all

Varnish Software Blog