准备环境:Centos 7
关闭防火墙、修改 seLinux 为警告模式
[root@fp-21 ~]# systemctl stop firewalld.service
[root@fp-21 ~]# setenforce 0
安装所属依赖
[root@fp-21 ~]# yum -y install autoconf.noarch automake.noarch jemalloc-devel.x86_64 libedit-devel.x86_64 libtool.x86_64 ncurses-devel.x86_64 pcre-devel.x86_64 pkgconfig.x86_64 python-docutils.noarch python-sphinx.noarch graphviz.x86_64
Loaded plugins: fastestmirror
Determining fastest mirrors
……
Complete!
上传源码包
[root@fp-21 ~]# cd /opt/
[root@fp-21 opt]# mkdir varnish
[root@fp-21 opt]# cd varnish
[root@fp-21 opt]# rz
[root@fp-21 varnish]# ls
varnish-6.3.2.tgz
查看一下这个包的类型,相关命令:Linux 基础命令 – file
[root@fp-21 varnish]# file varnish-6.3.2.tgz
varnish-6.3.2.tgz: gzip compressed data, from Unix, last modified: Fri Jan 31 20:27:18 2020, max compression
使用相关命令进行解压
[root@fp-21 varnish]# gunzip varnish-6.3.2.tgz
[root@fp-21 varnish]# ls
varnish-6.3.2.tar
[root@fp-21 varnish]# tar xf varnish-6.3.2.tar
[root@fp-21 varnish]# ls
varnish-6.3.2 varnish-6.3.2.tar
进入 varnish
[root@fp-21 varnish]# cd varnish-6.3.2/
[root@fp-21 varnish-6.3.2]# ll
total 948
-rw-r--r--. 1 1000 1000 63162 Jan 31 20:21 aclocal.m4
-rwxr-xr-x. 1 1000 1000 849 Dec 17 17:50 autogen.sh
drwxr-xr-x. 10 1000 1000 190 Jan 31 20:27 bin
drwxr-xr-x. 2 1000 1000 143 Jan 31 20:27 build-aux
-rw-r--r--. 1 1000 1000 95 Aug 2 2017 ChangeLog
-rw-r--r--. 1 1000 1000 8270 Jan 31 20:13 config.h.in
-rwxr-xr-x. 1 1000 1000 761298 Jan 31 20:21 configure
……
有两个可执行文件(autogen.sh、configure),先进行预编译
[root@fp-21 varnish-6.3.2]# ./autogen.sh
+ libtoolize --copy --force
……
lib/libvmod_debug/Makefile.am:9: 'lib/libvmod_debug/automake_boilerplate.am' included from here
+ autoconf
预编译没问题,接下来进行环境检测
[root@fp-21 varnish-6.3.2]# ./configure --prefix=/usr/local/varnish
checking for gcc... gcc
……
checking for a Python interpreter with version >= 3.4... none
configure: error: Python >= 3.4 is required.
错误:需要 python 3.4 以上版本
[root@fp-21 varnish-6.3.2]# python -V
Python 2.7.5
升级详细过程请参考:Centos7.6 下 Python2.7 升级为 Python3.7
[root@fp-21 varnish-6.3.2]# python -V
Python 3.7.3
再次检测安装环境
[root@fp-21 varnish-6.3.2]# ./configure --prefix=/usr/local/varnish
checking for gcc... gcc
checking whether the C compiler works... yes
……
config.status : executing Libtool commands
config.status : executing mkdir commands
没有问题,进行下一步
[root@fp-21 varnish-6.3.2]# make
make all-recursive
make[1]: Entering directory `/opt/varnish/varnish-6.3.2'
Making all in include
……
ModuleNotFoundError: No module named 'docutils'
make[2]: *** [vsl.7] Error 1
make[2]: Leaving directory `/opt/varnish/varnish-6.3.2/man'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/opt/varnish/varnish-6.3.2'
make: *** [all] Error 2
发现缺少东西,安装即可
[root@fp-21 varnish-6.3.2]# pip install docutils
Collecting docutils
Downloading https://files.pythonhosted.org/packages/81/44/8a15e45ffa96e6cf82956dd8d7af9e666357e16b0d93b253903475ee947f/docutils-0.16-py2.py3-none-any.whl (548kB)
100% |████████████████████████████████| 552kB 13kB/s
Installing collected packages: docutils
Successfully installed docutils-0.16
再次进行安装
[root@fp-21 varnish-6.3.2]# make
make all-recursive
make[1]: Entering directory `/opt/varnish/varnish-6.3.2'
Making all in include
……
make[2]: Leaving directory `/opt/varnish/varnish-6.3.2/man'
make[2]: Entering directory `/opt/varnish/varnish-6.3.2'
make[2]: Leaving directory `/opt/varnish/varnish-6.3.2'
make[1]: Leaving directory `/opt/varnish/varnish-6.3.2'
没问题,最后一步
[root@fp-21 varnish-6.3.2]# make install
Making install in include
make[1]: Entering directory `/opt/varnish/varnish-6.3.2/include'
make install-am
……
make[2]: Leaving directory `/opt/varnish/varnish-6.3.2'
make[1]: Leaving directory `/opt/varnish/varnish-6.3.2'
安装完成,做软链接
[root@fp-21 ~]# ln -s /usr/local/varnish/sbin/varnishd /usr/bin/varnishd
查看版本信息
[root@fp-21 ~]# varnishd -V
varnishd (varnish-6.3.2 revision 6870fd661a2b42c2e8adad838b5d92a71f27dccd)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2019 Varnish Software AS
启动服务
[root@fp-21 ~]# varnishd -a :6081 -T localhost:6802 -b localhost:8080
Debug: Version: varnish-6.3.2 revision 6870fd661a2b42c2e8adad838b5d92a71f27dccd
Debug: Platform: Linux,3.10.0-957.el7.x86_64,x86_64,-jnone,-sdefault,-sdefault,-hcritbit
Debug: Child (31574) Started
查看进程和端口
进程信息
[root@fp-21 ~]# ps -ef |grep varnishd
root 31564 1 0 06:42 ? 00:00:00 varnishd -a :6081 -T localhost:6802 -b localhost:8080
root 31574 31564 0 06:42 ? 00:00:00 varnishd -a :6081 -T localhost:6802 -b localhost:8080
root 31795 7788 0 06:44 pts/0 00:00:00 grep --color=auto varnishd
端口信息
[root@fp-21 ~]# ss -lntp |grep varnishd
LISTEN 0 10 127.0.0.1:6802 *:* users:(("varnishd",pid=31564,fd=9))
LISTEN 0 128 *:6081 *:* users:(("cache-main",pid=31574,fd=3),("varnishd",pid=31564,fd=3))
LISTEN 0 10 ::1:6802 :::* users:(("varnishd",pid=31564,fd=8))
LISTEN 0 128 :::6081 :::* users:(("cache-main",pid=31574,fd=5),("varnishd",pid=31564,fd=5))