varnish安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了varnish安装相关的知识,希望对你有一定的参考价值。

安装pcre
varnish 依赖pcre进行url正则匹配。

cd pcre-8.12
./configure --prefix=/usr/local/
make&&make install

编译
解压缩varnish源码包

wget http://repo.varnish-cache.org/source/varnish-3.0.4.tar.gz
cd /root
tar -zxvf varnish-3.0.4.tar.gz
cd varnish-3.0.4
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./configure --prefix=/usr/local/varnish
make && make install

 

配置文件路径vim /usr/local/varnish/etc/varnish/default.vcl

ln -s /usr/local/varnish/sbin/varnishd /usr/bin/varnishd

vim /usr/local/varnish/etc/varnish/default.vcl

 

 

#去掉注释

backend default {
.host = "192.168.66.139";
.port = "80";
}

 

#启动varnish

varnishd -f /usr/local/varnish/etc/varnish/default.vcl -s file,/var/varnish_cache,1G -T 0.0.0:2000 -a 0.0.0.0:80

 

http://192.168.66.140/

 

返回头信息:

Accept-Ranges:bytes
Age:0
Connection:keep-alive
Content-Length:10
Content-Type:text/html; charset=UTF-8
Date:Fri, 03 Jun 2016 08:34:41 GMT
ETag:"c0672-a-53433d4d6ce32"
Last-Modified:Wed, 01 Jun 2016 09:08:22 GMT
Server:Apache/2.2.15 (CentOS)
Via:1.1 varnish
X-Varnish:977689110

  安装成功!

 

以上是关于varnish安装的主要内容,如果未能解决你的问题,请参考以下文章

varnish安装使用

varnish使用yum安装及不同域名站点

varnish安装

varnishlogVarnishstat详解

linux环境下安装varnish

安装varnish服务器