安装依赖包
[root@xiaoxia ~]yum -y install readline-devel gcc ncurses-devel python-docutils pcre-devel
[root@xiaoxia ~]useradd -s /sbin/nologin varnish 创建varnish用户
[root@xiaoxia ~]wget 下载 varnish 源码包
[root@xiaoxia ~]tar -xf varnish-5.2.1.tgz
[root@xiaoxia ~]cd varnish-5.2.1
[root@xiaoxia varnish-5.2.1]./configure
[root@xiaoxia varnish-5.2.1]make && make install
[root@xiaoxia varnish-5.2.1]cp etc/example.vcl /usr/local/etc/default.vcl 复制配置文件模板到自定义位置
[root@xiaoxia varnish-5.2.1]vim /usr/local/etcdefault.vcl
backend default {
.host = "192.168.0.20"; 将此内容修改为后台web服务器的ip和网站程序占用的端口号
.port = "80";
}
[root@xiaoxia ~]varnishd -f /usr/local/etc/default.vcl 启动程序 注意:varnish程序是占用80端口,所以在开启varnish程序之前先关闭所有占用80端口的程序进程
[root@xiaoxia ~]varnishlog 日志文件