centos6.0 32位
Varnish3.0.2
我们先配置nginx环境.参考教程:http://blog.haohtml.com/archives/6051
并修改nginx的监听端口为81.下面我们varnish监听的端口为80端口.
==============================================================
目前varnish的最新版本为3.0.2,这里我们使用最新的稳定版本
cd /usr/local/soft
wget http://repo.varnish-cache.org/source/varnish-3.0.2.tar.gz
tar zxvf varnish-3.0.2.tar.gz
cd varnish-3.0.2
./configure --prefix=/usr/local/varnish
make && make install
如果在执行./configure命令的过程中遇到”No package ‘libpcre’ found”的错误提示信息的话,需要执行以下命令
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
即可(这个已经在前面配置nginx环境的时候,安装过了pcre库了,这里是环境变量的问题).
现在我们确认一下是否安装成功.
[root@bogon varnish-3.0.2]# ls /usr/local/varnish
bin etc include lib sbin share var
其中sbin目录里为varnish主程序文件,bin目录里为varnish的管理命令,etc目录为配置文件,share目录为手册,lib目录为一些库文件,include目录为一些程序所需的c语言里的.h头文件
varnish语法
[root@bogon varnish-3.0.2]#cd /usr/local/varnish/sbin
[root@bogon sbin]# ./varnishd --help
./varnishd: invalid option -- '-'
usage: varnishd [options]
-a address:port # HTTP listen address and port
-b address:port # backend address and port
# -b <hostname_or_IP>
# -b '<hostname_or_IP>:<port_or_service>'
-C # print VCL code compiled to C language
-d # debug
-f file # VCL script
-F # Run in foreground
-h kind[,hashoptions] # Hash specification
# -h critbit [default]
# -h simple_list
# -h classic
# -h classic,<buckets>
-i identity # Identity of varnish instance
-l shl,free,fill # Size of shared memory file
# shl: space for SHL records [80m]
# free: space for other allocations [1m]
# fill: prefill new file [+]
-M address:port # Reverse CLI destination.
-n dir # varnishd working directory
-P file # PID file
-p param=value # set parameter
-s kind[,storageoptions] # Backend storage specification
# -s malloc
# -s file [default: use /tmp]
# -s file,<dir_or_file>
# -s file,<dir_or_file>,<size>
# -s persist{experimenta}
# -s file,<dir_or_file>,<size>,<granularity>
-t # Default TTL
-S secret-file # Secret file for CLI authentication
-T address:port # Telnet listen address and port
-V # version
-w int[,int[,int]] # Number of worker threads
# -w <fixed_count>
# -w min,max
# -w min,max,timeout [default: -w2,500,300]
-u user # Priviledge separation user id
参数详解: