坑爹的 varnish-4 之 Ubuntu 安装手记

首先在varnish官网找到最新版:Varnish Cache releases

1
2
3
4
wget https://repo.varnish-cache.org/source/varnish-4.0.0-beta1.tar.gz
tar -vzxf varnish-4.0.0-beta1.tar.gz
cd varnish-4.0.0
./configure --prefix=/usr/local/varnish


出现错误1:大意是缺失curses/ncurses库,忘了截图。
解决方案:安装 ncurses在这里:http://www.gnu.org/software/ncurses/

1
2
3
4
5
6
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz
tar -vzxf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure
make
sudo make install

回到 varnish:

1
2
cd ../varnish-4.0.0
./configure --prefix=/usr/local/varnish

varnish-4.0.0报错

出现错误2:这次是 No package ‘libpcre’ found
解决方案:安装pcre
在这里:PCRE - Perl Compatible Regular Expressions 来一发:

1
2
3
4
5
6
wget http://hivelocity.dl.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.bz2
tar -xjvf pcre-8.35.tar.bz2
cd pcre-8.35
./configure
make
sudo make install

Let’s repeat again :

1
2
3
4
cd ../
./configure --prefix=/usr/local/varnish
make
make install

fatal error: editline/readline.h: No such file or directory  #  include

出现问题3:编译错误:fatal error: editline/readline.h: No such file or directory # include <editline/readline.h>
解决方案:安装 libedit在这里:http://sourceforge.net/projects/libedit/,流程如上不再重复。
出现问题4:编译 libedit 报错:

1
2
3
4
/usr/bin/ld: chared.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
chared.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libedit.so] Error 1

解决方案:实践证明这位哥们的方案有效:http://sourceforge.net/p/libedit/bugs/7/


安装好 libedit,继续 make varnish

varnish-4.0.0报错

出现问题5:编译错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Making all in varnishadm
make[3]: Entering directory `/home/yekz/varnish-4.0.0/bin/varnishadm'
CC varnishadm-varnishadm.o
varnishadm.c: In function ‘cli_write’:
varnishadm.c:81:2: error: implicit declaration of function ‘rl_callback_handler_remove’ [-Werror=implicit-function-declaration]
RL_EXIT(1);
^
varnishadm.c: In function ‘varnishadm_completion’:
varnishadm.c:223:3: error: implicit declaration of function ‘rl_completion_matches’ [-Werror=implicit-function-declaration]
matches = rl_completion_matches(text, command_generator);
^
varnishadm.c:223:11: error: assignment makes pointer from integer without a cast [-Werror]
matches = rl_completion_matches(text, command_generator);
^
varnishadm.c: In function ‘interactive’:
varnishadm.c:240:2: error: ‘rl_already_prompted’ undeclared (first use in this function)
rl_already_prompted = 1;
^
varnishadm.c:240:2: note: each undeclared identifier is reported only once for each function it appears in
varnishadm.c:241:2: error: implicit declaration of function ‘rl_callback_handler_install’ [-Werror=implicit-function-declaration]
rl_callback_handler_install("varnish> ", send_line);
^
varnishadm.c:304:4: error: implicit declaration of function ‘rl_forced_update_display’ [-Werror=implicit-function-declaration]
rl_forced_update_display();
^
varnishadm.c:307:4: error: implicit declaration of function ‘rl_callback_read_char’ [-Werror=implicit-function-declaration]
rl_callback_read_char();
^
cc1: all warnings being treated as errors
make[3]: *** [varnishadm-varnishadm.o] Error 1
make[3]: Leaving directory `/home/yekz/varnish-4.0.0/bin/varnishadm'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/yekz/varnish-4.0.0/bin'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/yekz/varnish-4.0.0'
make: *** [all] Error 2

解决方案:安装 libreadline : http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
问题详情可以在此处了解:https://www.varnish-cache.org/trac/ticket/1003


GOON!!!

出现问题6:编译错误:

1
2
3
4
5
6
7
8
9
10
make[3]: Entering directory `/home/yekz/varnish-4.0.0/doc/sphinx'
../../bin/varnishd/varnishd -x dumprstparam > include/params.rst
/home/yekz/varnish-4.0.0/bin/varnishd/.libs/lt-varnishd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
make[3]: *** [include/params.rst] Error 127
make[3]: Leaving directory `/home/yekz/varnish-4.0.0/doc/sphinx'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/yekz/varnish-4.0.0/doc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/yekz/varnish-4.0.0'
make: *** [all] Error 2

解决方案:使用 sudo make(有误,请参考下文,但不知为何此处使用 sudo 确实编译过了)

通过了!!!!!!!!!!!!!!!!!!!!


启动 varnish:

出现错误7:varnishd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决方案:Ubuntu下,pcre安装在 /usr/local/lib/pcre,而 varnish 似乎是在 /lib/pcre 找它。做个链接就行了:
sudo ln -s /usr/local/lib/libpcre.so.1.2.3 /lib/libpcre.so.1

收工!太坑了!!!!