varnish(未成)
varnish是一款高性能的开源HTTP缓存加速器,据说性能比squid强很多倍
http://ignum.dl.sourceforge.net/project/varnish/varnish/1.1.1/varnish-1.1.1.tar.gz
# tar zxvf /usr/local/src/varnish-1.1.1.tar.gz
# cd /usr/local/src/varnish-1.1.1
# ./autogen.sh
# ./configure --prefix=/usr/local/varnish
# make && make install
# mkdir /varnish
# chmod 777 /varnish
编写启动文件:
# vi /usr/local/varnish/sbin/varnish.sh
#!/bin/sh
date -u
/usr/local/varnish/sbin/varnishd -a 192.168.1.10:80 -s file,/varnish,1024m -f /usr/local/varnish/vcl.conf -T 192.168.1.10:3500 -p thread_pool_max=1500 -p thread_pools=5 -p listen_depth=512 -p client_http11=on -p backend_http11=on
:wq
编写VCL文件
# vi /usr/local/varnish/vcl.conf
backend yang {
set backend.host = "192.168.1.10";
set backend.port = "80";
}
sub vcl_recv {
if (req.request != "GET" && req.request != "HEAD") {
pipe;
}
if (req.http.Expect) {
pipe;
}
if (req.http.Authenticate || req.http.Cookie) {
pass;
}
if (req.request == "GET" && req.url ~ "\.(gif|jpg|swf|css|js)$") {
lookup;
}
lookup;
}
sub vcl_pipe {
pipe;
}
sub vcl_pass {
pass;
}
sub vcl_hash {
hash;
}
sub vcl_hit {
if (!obj.cacheable) {
pass;
}
deliver;
}
sub vcl_timeout {
discard;
}
sub vcl_discard {
discard;
}
:wq
启动varnish:
# /usr/local/varnish/sbin/varnish.sh
查看端口:
# netstat -ntpl varnishd
停止varnish:
# killall varnishd
开机自启动:
# vi /etc/rc.local
/usr/local/varnish/sbin/varnish.sh
:wq
注:未成,原因还在研究中
本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/881029如需转载请自行联系原作者
yangzhimingg