Install Varnish Cache on Windows with cygwin
Are you running a website on a (self-hosted) server? Is your web application loading slowly? Then this blog post might be interesting for you!
This post was imported from GitHub Gist.
What is Varnish Cache?
Varnish Cache is HTTP cache software that maximizes the speed of the content delivery from your web applications to the users.
Build instructions with cygport packages (for development)
Cygport source packages can be build using cygport program. Cygport can be installed using cygwin setup.exe.
- Install CYGWIN environment with cygport tool
- Download cygport
varnish-*-src.tar.xzvarnish package files from SourceForge - Uncompress
tar.xzfiles to/usr/srcdirectory (All files!) - Enter the directory in cygwin:
cd /cygdrive/c/cygwin64/usr/src -
Execute cygport commands:
1 2 3
cygport varnish-{version}.cygport prep cygport varnish-{version}.cygport compile cygport varnish-{version}.cygport install - Compiled binaries are copied to
varnish-{version}/inst
In my case:
1
2
3
4
cd /cygdrive/c/cygwin64/usr/src
cygport varnish-4.1.0-1.cygport prep
cygport varnish-4.1.0-1.cygport compile
cygport varnish-4.1.0-1.cygport install
Install Full Cygwin environment with varnish package (for production)
The tar.xz package file is installed inside Cygwin environment using cygwin installer:
- 32 bits installer: https://cygwin.com/setup-x86.exe
- 64 bits installer: https://cygwin.com/setup-x86_64.exe
Follow this steps:
- Download
setup-x64.exe(32 bits) orsetup-x86_64.exe(64 bits) atlocalhost. - Install CYGWIN enviroment executing installer.
On package selection list, select varnish package from package list in Web category, package will be download from cygwin servers:
Install varnishd as a Windows service
Run as an administrator:
1
cygrunsrv --install varnishd --path /cygdrive/c/cygwin64/usr/sbin/varnishd.exe
or
1
cygrunsrv --install varnish --path /cygdrive/c/cygwin64/usr/sbin/varnishd.exe -a "-P /cygdrive/c/cygwin64/var/varnish/varnish.pid -f /cygdrive/c/cygwin64/etc/varnish/default.vcl -a :81 -T 127.0.0.1:6082 -t 120 -S /cygdrive/c/cygwin64/etc/varnish/secret -s file,/cygdrive/c/cygwin64/var/varnish/varnish_storage.bin,2G -F"
Uninstall varnishd as a Windows service
Run as an administrator:
1
cygrunsrv --remove varnishd
Start varnishd as a Windows service
1
cygrunsrv --start varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000
or
1
cygrunsrv --start varnish
Stop varnishd as a Windows service
1
cygrunsrv --stop
Helpful resources
You liked the tutorial? Interested in coding together? Feel free to contact me.

