---
title: 源码编译安装
description: "| 适用的软件版本 | 是否适配CentOS 7.6 | 是否适配CentOS 8.1 | 是否适配openEuler 20.03 LTS SP1 |"
url: https://www.hikunpeng.com/document/detail/zh/kunpengwebs/ecosystemEnable/Varnish/kunpengvarnish_02_0010.html
sourcePath: /source/zh/kunpengwebs/ecosystemEnable/Varnish/kunpengvarnish_02_0010.html
indexId: 324b380e3d367789bf342346a7302234324f1346eeaafd0fb6997c2f136611eb74
---
# 源码编译安装

| 适用的软件版本 | 是否适配CentOS 7.6 | 是否适配CentOS 8.1 | 是否适配openEuler 20.03 LTS SP1 |
| --- | --- | --- | --- |
| Varnish 6.2.0 | 是 | 否 | 是 |
| Varnish 6.5.1 | 否 | 是 | 否 |


下文命令中的x.x.x代表Varnish的版本号。


#### 获取源码

1. 在本地浏览器下载Varnish源码。

  -     Varnish 6.2.0(https://varnish-cache.org/_downloads/varnish-6.2.0.tgz)

  -     Varnish 6.5.1(https://varnish-cache.org/_downloads/varnish-6.5.1.tgz)

2. 将源码复制至服务器“/home”目录。
  若服务器可以访问网络，则可以直接在服务器上使用wget命令下载源码。 1 cd /home 1 wget https://varnish-cache.org/_downloads/varnish-x.x.x.tgz --no-check-certificate


#### 编译和安装

1. 进入“home”目录。
  1 cd /home/

2. 解压源码包。
  1 tar -zxvf varnish-x.x.x.tgz

3. 进入源码目录。
  1 cd /home/varnish-x.x.x/

4. 执行自动编译。
  1 sh autogen.sh

5. 检查依赖。
  1 ./configure --prefix=/usr/local/varnish

  --prefix=PATH：指定Varnish的安装目录。

6. 编译安装Varnish。
  1 make -j60 && make install


#### 配置文件

1. 在Varnish安装路径中创建配置文件所需的文件夹。
  1 cd /usr/local/varnish && mkdir config

2. 复制配置文件到“config”中。
  1 cp /usr/local/varnish/share/doc/varnish/example.vcl /usr/local/varnish/config/default.vcl
