You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Amazon Linux 2023中安装Varnish Cache 6?

如何在Amazon Linux 2023中安装Varnish Cache 6?

我明白你在Amazon Linux 2023上安装Varnish Cache 6时遇到的麻烦——默认源找不到包、rpm安装依赖一堆问题、packagecloud源也踩坑,确实挺闹心的。下面给你两种靠谱的解决方法,优先推荐源安装,更省心:

方法一:通过Varnish官方LTS源安装(推荐)

Amazon Linux 2023兼容RHEL 9的软件包生态,我们可以直接添加Varnish 6.0 LTS的官方源来解决依赖问题:

  1. 先安装必要的工具并导入Varnish的GPG密钥:
sudo dnf install -y curl
curl -s https://packagecloud.io/varnishcache/varnish60lts/gpgkey | sudo gpg --dearmor -o /etc/pki/rpm-gpg/RPM-GPG-KEY-Varnish
  1. 创建Varnish 6.0 LTS的repo配置文件:
sudo tee /etc/yum.repos.d/varnish60lts.repo <<EOF
[varnish60lts]
name=varnishcache_varnish60lts
baseurl=https://packagecloud.io/varnishcache/varnish60lts/el/9/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-Varnish
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF
  1. 启用Amazon Linux 2023的CRB源(提供部分依赖包):
sudo dnf config-manager --enable crb
  1. 最后安装Varnish:
sudo dnf install -y varnish

安装完成后可以用varnishd -V验证版本,还能通过systemctl start varnish启动服务。

方法二:编译安装(适合自定义需求场景)

如果源安装还是遇到问题,或者你需要自定义编译参数,可以选择源码编译:

  1. 安装编译所需的依赖包:
sudo dnf install -y gcc make autoconf automake libtool pkgconfig pcre-devel libedit-devel ncurses-devel jemalloc-devel
  1. 下载Varnish 6.0 LTS的最新源码包(这里以6.0.11为例):
curl -O https://varnish-cache.org/downloads/varnish-6.0.11.tgz
  1. 解压并进入源码目录:
tar xzf varnish-6.0.11.tgz
cd varnish-6.0.11
  1. 配置编译参数(默认配置即可满足大部分需求):
./configure
  1. 编译并安装:
make && sudo make install

编译安装后需要手动配置systemd服务来管理Varnish,你可以参考官方的服务模板创建/etc/systemd/system/varnish.service文件,然后通过systemctl daemon-reload和systemctl start varnish启动服务。

备注:内容来源于stack exchange,提问作者Duke

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 08:23:14