在CentOS下安裝Varnish Cache RedHat/CentOS 系統內容下 varnish 的依賴關係如果您是 RedHat/CentOS 系統想安裝 varnish,您需要安裝以下軟體包:automakeautoconflibtoolncurses-devellibxsltgroffpcre-develpkgconfig 以下是在配置好 yum 包管理器的情況下運行yum install -y automake autoconf libtool ncurses-devel libxslt groff pcre-devel pkgconfig [root@node18 ~]# yum install -y automake autoconf libtool ncurses-devel libxslt groff pcre-devel pkgconfigLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.grandcloud.cn * extras: mirrors.grandcloud.cn * updates: mirrors.grandcloud.cnSetting up Install ProcessPackage automake-1.9.6-2.3.el5.noarch already installed and latest versionPackage autoconf-2.59-12.noarch already installed and latest versionPackage libtool-1.5.22-7.el5_4.i386 already installed and latest versionPackage ncurses-devel-5.5-24.20060715.i386 already installed and latest versionPackage libxslt-1.1.17-4.el5_8.3.i386 already installed and latest versionPackage groff-1.18.1.1-13.el5.i386 already installed and latest versionPackage pcre-devel-6.6-6.el5_6.1.i386 already installed and latest versionPackage 1:pkgconfig-0.21-2.el5.i386 already installed and latest versionNothing to do[root@node18 ~]# 下載varnish原始碼並編譯安裝 mkdir varnish_setupcd varnish_setup/wget http://repo.varnish-cache.org/source/varnish-2.1.5.tar.gztar zxf varnish-2.1.5.tar.gzcd varnish-2.1.5./autogen.sh./configure --prefix=/usrmakecd bin/varnishtest && ./varnishtest tests/*.vtc # <== 這一步執行測試,很費時,可省略cd ../.. # <=== 如果執行了測試,否則執行安裝make install注意:本文的安裝與預設安裝不同varnishd將被安裝到 /usr/sbin/varnishd設定檔 /usr/etc/varnish/default.vcl 下面是安裝的詳細記錄:[root@node18 ~]# mkdir varnish_setup[root@node18 ~]# cd varnish_setup/[root@node18 varnish_setup]# wget http://repo.varnish-cache.org/source/varnish-2.1.5.tar.gz--2012-11-20 10:23:32-- http://repo.varnish-cache.org/source/varnish-2.1.5.tar.gz正在解析主機 repo.varnish-cache.org... 194.31.39.155Connecting to repo.varnish-cache.org|194.31.39.155|:80... 已串連。已發出 HTTP 要求,正在等待回應... 200 OK長度:1530856 (1.5M) [application/x-gzip]Saving to: `varnish-2.1.5.tar.gz' 100%[======================================>] 1,530,856 51.2K/s in 20s 2012-11-20 10:23:53 (73.2 KB/s) - `varnish-2.1.5.tar.gz' saved [1530856/1530856] [root@node18 varnish_setup]# [root@node18 varnish_setup]# tar zxf varnish-2.1.5.tar.gz [root@node18 varnish_setup]# cd varnish-2.1.5[root@node18 varnish-2.1.5]# lsaclocal.m4 config.guess depcomp install-sh Makefile.in varnishapi.pc.inautogen.sh config.h.in doc lib manbin config.sub etc LICENSE missingChangeLog configure include ltmain.sh READMEcompile configure.ac INSTALL Makefile.am redhat[root@node18 varnish-2.1.5]# [root@node18 varnish-2.1.5]# ./autogen.sh + aclocal+ libtoolize --copy --force+ autoheader+ automake --add-missing --copy --foreign+ autoconf[root@node18 varnish-2.1.5]# ./configure --prefix=/usrchecking build system type... i686-redhat-linux-gnuchecking host system type... i686-redhat-linux-gnuchecking target system type... i686-redhat-linux-gnuchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for gcc... gccchecking for C compiler default output file name... a.outchecking whether the C compiler works... yes...configure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating bin/Makefileconfig.status: creating bin/varnishadm/Makefileconfig.status: creating bin/varnishd/Makefileconfig.status: creating bin/varnishlog/Makefileconfig.status: creating bin/varnishhist/Makefileconfig.status: creating bin/varnishncsa/Makefileconfig.status: creating bin/varnishreplay/Makefileconfig.status: creating bin/varnishstat/Makefileconfig.status: creating bin/varnishsizes/Makefileconfig.status: creating bin/varnishtest/Makefileconfig.status: creating bin/varnishtop/Makefileconfig.status: creating doc/Makefileconfig.status: creating doc/sphinx/Makefileconfig.status: creating etc/Makefileconfig.status: creating include/Makefileconfig.status: creating lib/Makefileconfig.status: creating lib/libvarnish/Makefileconfig.status: creating lib/libvarnishapi/Makefileconfig.status: creating lib/libvarnishcompat/Makefileconfig.status: creating lib/libvcl/Makefileconfig.status: creating lib/libjemalloc/Makefileconfig.status: creating man/Makefileconfig.status: creating redhat/Makefileconfig.status: creating varnishapi.pcconfig.status: creating config.hconfig.status: executing depfiles commands[root@node18 varnish-2.1.5]# makemake all-recursivemake[1]: Entering directory `/root/varnish_setup/varnish-2.1.5'Making all in includemake[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/include'make[2]: Nothing to be done for `all'.make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/include'Making all in libmake[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/lib'Making all in libvarnishcompatmake[3]: Entering directory `/root/varnish_setup/varnish-2.1.5/lib/libvarnishcompat'if /bin/sh ../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../../include -g -O2 -MT daemon.lo -MD -MP -MF ".deps/daemon.Tpo" -c -o daemon.lo daemon.c; \ then mv -f ".deps/daemon.Tpo" ".deps/daemon.Plo"; else rm -f ".deps/daemon.Tpo"; exit 1; fimkdir .libs gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../../include -g -O2 -MT daemon.lo -MD -MP -MF .deps/daemon.Tpo -c daemon.c -fPIC -DPIC -o .libs/daemon.o...mkdir .libsgcc -g -O2 -o .libs/varnishsizes varnishsizes.o ../../lib/libvarnish/.libs/libvarnish.so -lrt -lnsl ../../lib/libvarnishcompat/.libs/libvarnishcompat.so ../../lib/libvarnishapi/.libs/libvarnishapi.so -lpcre -lm -lcurses -lpthread creating varnishsizesmake[3]: Leaving directory `/root/varnish_setup/varnish-2.1.5/bin/varnishsizes'make[3]: Entering directory `/root/varnish_setup/varnish-2.1.5/bin'make[3]: Nothing to be done for `all-am'.make[3]: Leaving directory `/root/varnish_setup/varnish-2.1.5/bin'make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/bin'Making all in manmake[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/man'make[2]: Nothing to be done for `all'.make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/man'Making all in etcmake[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/etc'make[2]: Nothing to be done for `all'.make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/etc'Making all in docmake[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/doc'Making all in sphinxmake[3]: Entering directory `/root/varnish_setup/varnish-2.1.5/doc/sphinx'make[3]: Nothing to be done for `all'.make[3]: Leaving directory `/root/varnish_setup/varnish-2.1.5/doc/sphinx'make[3]: Entering directory `/root/varnish_setup/varnish-2.1.5/doc'make[3]: Nothing to be done for `all-am'.make[3]: Leaving directory `/root/varnish_setup/varnish-2.1.5/doc'make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/doc'Making all in redhatmake[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/redhat'make[2]: Nothing to be done for `all'.make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/redhat'make[2]: Entering directory `/root/varnish_setup/varnish-2.1.5'make[2]: Nothing to be done for `all-am'.make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5'make[1]: Leaving directory `/root/varnish_setup/varnish-2.1.5'[root@node18 varnish-2.1.5]# [root@node18 varnish-2.1.5]# cd bin/varnishtest && ./varnishtest tests/*.vtc# top TEST tests/a00000.vtc passed (0.001s)# top TEST tests/a00001.vtc passed (0.001s)# top TEST tests/a00002.vtc passed (0.001s)# top TEST tests/a00003.vtc passed (0.001s)# top TEST tests/a00004.vtc passed (0.001s)# top TEST tests/a00005.vtc passed (0.001s)# top TEST tests/a00006.vtc passed (0.001s)# top TEST tests/a00007.vtc passed (0.001s)# top TEST tests/a00008.vtc passed (1.806s)# top TEST tests/a00009.vtc passed (0.256s)# top TEST tests/a00010.vtc passed (0.002s)# top TEST tests/b00000.vtc passed (0.757s)# top TEST tests/b00001.vtc passed (0.675s)# top TEST tests/b00002.vtc passed (0.683s)...# top TEST tests/v00023.vtc passed (0.575s)# top TEST tests/v00024.vtc passed (0.587s)# top TEST tests/v00025.vtc passed (0.673s)# top TEST tests/v00026.vtc passed (0.590s)# top TEST tests/v00028.vtc passed (0.581s)# top TEST tests/v00029.vtc passed (1.310s)# top TEST tests/v00030.vtc passed (0.585s)# top Slowest test: tests/p00005.vtc 8.022s# top Total tests run: 196# top Total duration: 204.346s[root@node18 varnishtest]# [root@node18 varnishtest]# cd ../..[root@node18 varnish-2.1.5]# make installMaking install in includemake[1]: Entering directory `/root/varnish_setup/varnish-2.1.5/include'make[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/include'make[2]: Nothing to be done for `install-exec-am'.test -z "/usr/include/varnish" || mkdir -p -- "/usr/include/varnish" /usr/bin/install -c -m 644 'shmlog.h' '/usr/include/varnish/shmlog.h' /usr/bin/install -c -m 644 'shmlog_tags.h' '/usr/include/varnish/shmlog_tags.h' /usr/bin/install -c -m 644 'stat_field.h' '/usr/include/varnish/stat_field.h' /usr/bin/install -c -m 644 'stats.h' '/usr/include/varnish/stats.h' /usr/bin/install -c -m 644 'varnishapi.h' '/usr/include/varnish/varnishapi.h'make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/include'make[1]: Leaving directory `/root/varnish_setup/varnish-2.1.5/include'Making install in lib...Making install in redhatmake[1]: Entering directory `/root/varnish_setup/varnish-2.1.5/redhat'make[2]: Entering directory `/root/varnish_setup/varnish-2.1.5/redhat'make[2]: Nothing to be done for `install-exec-am'.make[2]: Nothing to be done for `install-data-am'.make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5/redhat'make[1]: Leaving directory `/root/varnish_setup/varnish-2.1.5/redhat'make[1]: Entering directory `/root/varnish_setup/varnish-2.1.5'make[2]: Entering directory `/root/varnish_setup/varnish-2.1.5'make[2]: Nothing to be done for `install-exec-am'./root/varnish_setup/varnish-2.1.5/install-sh -d -m 0755 /usr/var/varnishtest -z "/usr/lib/pkgconfig" || mkdir -p -- "/usr/lib/pkgconfig" /usr/bin/install -c -m 644 'varnishapi.pc' '/usr/lib/pkgconfig/varnishapi.pc'make[2]: Leaving directory `/root/varnish_setup/varnish-2.1.5'make[1]: Leaving directory `/root/varnish_setup/varnish-2.1.5'[root@node18 varnish-2.1.5]# [root@node18 varnish-2.1.5]# whereis varnishvarnish: /usr/etc/varnish /usr/include/varnish[root@node18 varnish-2.1.5]# whereis varnishdvarnishd: /usr/sbin/varnishd /usr/man/man1/varnishd.1[root@node18 varnish-2.1.5]# ls /usr/etc/varnish/default.vcl /usr/etc/varnish/default.vcl[root@node18 varnish-2.1.5]#