編譯自:install
安裝 Varnish 有兩種方式:binary packeges,編譯安裝。
這里只摘取 RetHat / CentOS 安裝的說明。
最新 rpm 包,以及源碼可在如下地址下載:http://repo.varnish-cache.org
目錄:
- 在 CentOS 上使用 rpm 安裝最新的 Varnish
- 在 CentOS 上使用 yum 安裝最新的 Varnish
- 在 CentOS 上編譯安裝最新的 Varnish
在 CentOS 上使用 rpm 安裝最新的 Varnish
可使用 wget 直接下載 rpm 包:
wget http://repo.varnish-cache.org/redhat/varnish-4.0/el6/x86_64/varnish/varnish-4.0.3-1.el6.x86_64.rpm
在 CentOS 上使用 yum 安裝最新的 Varnish
除了下載 rpm 包,或者下載源碼 tarball 進(jìn)行編譯安裝,也可以安裝 Varnish Cache 的 repo,然后使用 yum install varnish 進(jìn)行自動(dòng)安裝。
官方 package:
Varnish 項(xiàng)目維護(hù)有官方 rpm package,適用于 Enterprise Linux。在 EL6 和 EL7 上可安裝 Varnish Cache 4.0 和 4.1。
Varnish 4.1
yum install epel-release
rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.1.el7.rpm
(or: rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.1.el6.rpm for RHEL6)
yum install varnish
Varnish 4.0
For RHEL 6 or a compatible distribution, use:
yum install epel-release
rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
yum install varnish
For RHEL 7 and compatible distributions, use:
yum install epel-release
rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el7.rpm
yum install varnish
rpm 選項(xiàng)說明:
--nosignature
Don't verify package or header signatures when reading.
-i, --info
Display package information, including name, version, and description. This uses the --queryformat
if one was specified.
僅在進(jìn)行初始化安裝時(shí),需要選項(xiàng) –no-signature , 因?yàn)?Varnish GPG key 不在 yum keyring 之中。
執(zhí)行 rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm 之后,自動(dòng)生成了 varnish.repo 文件
[root@vm_mac]# rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
[root@vm_mac]# ll /etc/yum.repos.d/
..
-rw-r--r-- 1 root root 196 Jun 19 2014 varnish.repo
[root@vm_mac haproxy]# cat /etc/yum.repos.d/varnish.repo
[varnish-4.0]
name=Varnish 4.0 for Enterprise Linux
baseurl=https://repo.varnish-cache.org/redhat/varnish-4.0/el6/$basearch
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-VARNISH
于是可以直接使用 yum install varnish 進(jìn)行安裝。
在 CentOS 上編譯安裝最新的 Varnish
如果要編譯安裝 Varnish,使用 wget 直接下載源碼 tarbll:
wget http://repo.varnish-cache.org/source/varnish-4.0.3.tar.gz
編譯安裝依賴于以下的 package,要先安裝這些包:
autoconf
automake
jemalloc-devel
libedit-devel
libtool
ncurses-devel
pcre-devel
pkgconfig
python-docutils
python-sphinx
編譯 Varnish:
cd varnish-cache
sh autogen.sh
sh configure
make
configure 腳本可接受一些選項(xiàng),不過暫時(shí)可不用考慮選項(xiàng)設(shè)置,因?yàn)閹缀跛嘘P(guān)于 Varnish 的屬性,可通過運(yùn)行時(shí)參數(shù)進(jìn)行調(diào)整。
安裝前,執(zhí)行測(cè)試,可能需要幾分鐘:
make check
如果出現(xiàn)幾個(gè)失敗測(cè)試也不用擔(dān)心,但如果出現(xiàn)大量 fails,特別是 b00000.vtc test fails,就要找找原因了。
安裝:
sudo make install
Varnish 被安裝在 /usr/local
varnish 可執(zhí)行文件在 /usr/local/sbin/varnishd
默認(rèn)的配置文件為 /usr/local/etc/varnish/default.vcl