centos 5.5 x86_64
//软体:
varnish-2.1.5.tar.gz
//安装依赖包:
>yum install -y automake autoconf libtool ncurses-devel libxslt groff pcre-devel pkgconfig
//编译安装varnish
>tar zxvf varnish-2.1.5.tar.gz
>cd varnish-2.1.5
>./configure --prefix=/usr/local/varnish PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
>make
>make install
//创建简单配置文件
>vi /usr/local/varnish/etc/varnish/test.vcl
backend baidu {
.host = "220.181.111.147";
.port = "80";
}
#
sub vcl_recv {
if(req.http.host ~ "www.baidu.com"){
set req.backend = baidu;
}
else {
error 404 "NO CACHE!";
}
}
//创建varnish用户和组
>groupadd www
>useradd -r -g www www
//创建缓存文件
>mkdir -p /data/varnish/
//更改权限
>chown -R www:www /data/varnish/
//启动
>/usr/local/varnish/sbin/varnishd -u www -g www -f /usr/local/varnish/etc/varnish/test.vcl -a 10.32.33.220:80 -s file,/data/varnish/cache/varnish_cache.data,256M -w 10,5120,10 -T 127.0.0.1:3000
//停用
>pkill varnishd
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。