varnish for windows 安装与配置
最近公司老大们要做网站加速,看着varnish评论不错,就选它了,网站平台是windows2003的,要和varnish放在一台机器上。这里想先说说博主辛苦一天安装配置下来的结果:https://www.varnish-cache.org/trac/wiki/VarnishOnCygwinWindows
Remember that Varnish on Cygwin Windows is not recommended for productions sites and it is only a proof-of-concept that can be used to test application on Windows or for checking you VCL while in that platform.
windows版的varnish主要只是测试应用和检查VCL规则用的...没有实际加速意义。
http://sourceforge.net/projects/cygvarnish/files/windows-zip-bundle/ 这是博主用的,但是不是官方的
官方的在这里:
There are two options for installing Varnish on Windows:
Install full Cygwin environment with varnish package. Recommended option
Install Varnish zip bundle, inside it includes Varnish binaries, GCC compiler, Cygwin, PDCurses and PCRE DLLs.
Sources can be built using:
Cygport packages ( https://sourceforge.net/projects/cygvarnish/files/cygport-packages/)
Varnish source and patch files ( https://sourceforge.net/projects/cygvarnish/files/patch-files/)
那么下面开始正式的安装了:
将下载的包解压,路径为C:\varnish\ 添加环境变量 $PATH=C:\varnish\bin\
将C:\varnish\etc\default.vcl 配置文件打开,去掉里面的注释。
1 backend default {
2.host = "127.0.0.1";
3.port = "8080";
4}
.host是web服务器地址,.port是web服务器监听端口,博主的varnish和web服务器装在同一台机器上,所以apache监听192.168.0.25:8080,把80端口给varnish。
下面是开启varnish监听:用CMD
C:\>varnishd -a 192.168.0.25:80 -T :3500 -f /cygdrive/c/varnish/etc/default.vcl -s malloc,1000M
详细说下参数:
-a varnish所在的缓存服务器地址与端口
-T 据说是什么控制程序端口,没试出来,欢迎知道的说下~
-f 配置文件的路径,这里说下,用C:\这样的windows路径是不行的,要用cygdrive/c,博主在这里纠结了很久
-s 有malloc和file两个参数,一个是把缓存放在内存里面,一个是放在文件里面,file的格式是 -s file,/cygdrive/c/.../.../cache,1000M,最后这个是缓存大小
开启varnish后可以在进程里面看看有没有一个叫varnish的进程,如果有,那就是开启了~
那么现在去看看varnish的监听和缓存情况。
访问192.168.0.25,可以看到网站被加载出来了~
查看response,可以看到多了Age项和X-varnish项~说明varnish已经开启,并且能将80监听的请求转给8080的web服务器了~
然后就是配置vcl文件,编写缓存规则~这里就不详细说了~因为博主现在也没闹明白~持续更新中...
页:
[1]