Skip to content

varnish Basic

varnish Basic

从epel仓库中安装

Terminal window
yum install epel-release -y
yum install varnish

epel仓库中的varnish版本为4.0.5,截止目前,官方最新版本为6.4.0

从官方仓库中安装较新版本

5.2.0版本为例

Terminal window
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish52/script.rpm.sh | sudo bash
yum install -y varnish

编译安装

  1. Download the appropriate release tarball, which you can find on https://varnish-cache.org/releases/ .

  2. To build Varnish on a Red Hat or CentOS system, this command should install required packages (replace sudo yum install if needed):

Terminal window
sudo yum install \
make \
autoconf \
automake \
jemalloc-devel \
libedit-devel \
libtool \
ncurses-devel \
pcre-devel \
pkgconfig \
python-docutils \
python-sphinx

Optionally, to rebuild the svg files:

Terminal window
yum install graphviz

Optionally, to pull from a repository:

Terminal window
yum install git
  1. The configuration will need the dependencies above satisfied. Once that is taken care of:
Terminal window
cd varnish-cache
sh autogen.sh
sh configure
make

The configure script takes some arguments, but more likely than not you can forget about that for now, almost everything in Varnish can be tweaked with run time parameters.

  1. Before you install, you may want to run the test suite, make a cup of tea while it runs, it usually takes a couple of minutes:
Terminal window
make check
  1. And finally, the true test of a brave heart: sudo make install

Varnish will now be installed in /usr/local. The varnishd binary is in /usr/local/sbin/varnishd. To make sure that the necessary links and caches of the most recent shared libraries are found, run sudo ldconfig.

启动

使用systemctl start varnish即可,手动启动使用一下命令:

Terminal window
varnishd -a :6081 -T localhost:6082 -b localhost:8080

参考链接