降级Varnish至6.0.11后安装MI-varnish6-modules遇依赖错误求助
Varnish降级后模块安装依赖错误解决方案
问题本质
你安装的MI-varnish6-modules-0.15.0-8.el7.x86_64是为Varnish 6.2.x编译的,依赖该版本对应的libvarnishapi.so.2库;而降级后的Varnish 6.0.11使用的是libvarnishapi.so.1库,版本不匹配导致依赖失败。
可行解决方案
1. 匹配模块与Varnish版本
- 查找或获取针对Varnish 6.0.x编译的
MI-varnish6-modules包,确保模块的编译版本与当前Varnish版本完全对应,直接安装即可解决依赖问题。
2. 从源码编译适配版本的模块
如果找不到对应预编译包,手动编译适配Varnish 6.0.11的模块:
- 先安装编译依赖:
yum install -y gcc make varnish-devel-6.0.11-*.el7.x86_64 pkgconfig - 若使用官方varnish-modules,选择与Varnish 6.0.x兼容的版本(如0.11.x系列);若是定制的MI版本,获取对应源码。
- 编译时指定自定义安装的Varnish配置路径(如果Varnish安装在
/nm/local):PKG_CONFIG_PATH=/nm/local/lib64/pkgconfig ./configure make make install
编译完成后,生成的模块会适配当前Varnish的库版本,消除依赖错误。
3. 修正RPM重新编译的问题
之前修改spec编译失败,大概率是依赖指定错误或编译环境残留旧版本:
- 卸载所有Varnish 6.2.x相关包,包括
varnish-devel - 安装Varnish 6.0.11的
varnish-devel包 - 修改spec文件:将依赖中的
libvarnishapi.so.2替换为libvarnishapi.so.1,并调整版本约束为6.0.11对应的值 - 重新编译RPM,生成的包将适配当前Varnish版本
4. 临时绕过依赖(不推荐)
仅用于紧急测试,可能导致运行异常:
- 强制安装模块包:
rpm -ivh --nodeps MI-varnish6-modules-0.15.0-8.el7.x86_64.rpm - 创建软链接让模块找到旧版本库:
ln -s /nm/local/lib64/varnish/libvarnishapi.so.1 /nm/local/lib64/varnish/libvarnishapi.so.2
内容的提问来源于stack exchange,提问作者Kodmur Ayesha
相关产品推荐
相关产品推荐

