1)编译安装软件
1.[root@proxy ~]# yum -y install gcc readline-devel //安装软件依赖包
2.[root@proxy ~]# yum -y install ncurses-devel //安装软件依赖包
3.[root@proxy ~]# yum -y install pcre-devel //安装软件依赖包
4.[root@proxy ~]# yum -y install python-docutils //安装软件依赖包
5. [root@proxy ~]# useradd -s /sbin/nologin varnish //创建账户
6.[root@proxy ~]# tar -xf varnish-5.2.1.tar.gz
7.[root@proxy ~]# cd varnish-5.2.1
8.[root@proxy varnish-5.2.1]# ./configure
9.[root@proxy varnish-5.2.1]# make && make install
2)复制配置文件(注意相对路径与绝对路径)
1.[root@proxy varnish-5.2.1]# cp etc/example.vcl /usr/local/etc/default.vcl
3)修改代理配置文件
1.[root@proxy ~]# vim /usr/local/etc/default.vcl
2.backend default {
3. .host = “192.168.2.100”;
4. .port = “80”;
5. }
4)启动服务
- [root@proxy ~]# varnishd -f /usr/local/etc/default.vcl
2.//varnishd命令的其他选项说明如下:
3.//varnishd -s malloc,128M 定义varnish使用内存作为缓存,空间为128M
4.//varnishd -s file,/var/lib/varnish_storage.bin,1G 定义varnish使用文件作为缓存