varnish安装

本文详细介绍如何在Linux环境下从零开始部署Varnish缓存服务器,包括安装必要的依赖包、编译并配置Varnish,以及与后端Web服务器的联动测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先准备环境:
上传软解包和依赖包:
libedit-devel-3.0-12.20121213cvs.el7.x86_64.rpm
python-docutils-0.11-0.2.20130715svn7687.el7.noarch.rpm
varnish-5.2.1.tgz

yum install -y gcc gcc-c++ make  //安装编译器和环境

安装依赖关系包和所需要的插件:

yum install -y \
libtool \
ncourses-devel \
pcre-devel \
libedit-devel \
libxslt \
groff \
pkgconfig \
ncurses-devel \
python-*
rpm -ivh libedit-devel-3.0-12.20121213cvs.el7.x86_64.rpm
rpm -ivh python-docutils-0.11-0.2.20130715svn7687.el7.noarch.rpm
tar  xf  varnish-5.2.1.tgz   -C  /opt      //解压到opt
cd /opt/varnish-5.2.1/    //进入解压后的文件夹中定义需要的模块
sh autogen.sh   //检查系统环境

在这里插入图片描述

./configure \
--prefix=/usr/local/varnish \
--enable-debugging-symbols \
--enable-developer-warnings
make && make install
cd /usr/local/varnish/
ln -s /usr/local/varnish/sbin/varnishd /usr/sbin/
ln -s /usr/local/varnish/bin/* /usr/local/bin/
cp /usr/local/varnish/share/doc/varnish/example.vcl /usr/local/varnish/default.vcl
//配置文件模板拷贝出来用
vi /usr/local/varnish/default.vclg
修改以下内容:
backend  default  {
		.host = "192.168.80.101";
		.port = "80";
}

在这里插入图片描述

 varnishd -f /usr/local/varnish/default.vcl -a 0.0.0.0:80   
//#指定监听的ip和端口启动varnish  

netstat -anpt | grep varnishd

在这里插入图片描述
在另一台linux虚拟机上搭建一个web服务器(101):

yum install -y httpd
vi /var/www/html/index.html
<h1>server 1</h1>
systemctl start httpd

测试,在windows浏览器中输入http://192.168.80.101(varnish服务器的ip地址)
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值