在FreeBSD 11里安装apache24 - wordpress5 - varnish5 - hitch

过程:

1.安装好apache24,站点szt.anqun.org安装好wordpress程序,运行在8080端口

2.pkg install varnish5 # 安装 varnish

3.sysrc varnishd_enable=YES # 启用 varnishd 服务

4.sysrc varnishd_config="/usr/local/etc/varnish" # 添加 varnishd 服务的配置文件,举例文件在这里:https://github.com/pranksinatra/gc-varnish-config/blob/master/default.vcl,视需求添加 set beresp.ttl = 1h; 及是否保留 unset resp.http.X-Varnish;
freebsd-wordpress-varnish-hitch-1.png

4.pkg install hitch # 安装 hitch ,让它提供https

5.vi /usr/local/etc/hitch # 编辑hitch配置文件,根据需求更改端口,本例是监听443端口,后端是varnishd的80端口
freebsd-wordpress-varnish-hitch-2.png

6.如wordpress后台https访问出现跳转循环,请在wp-config.php里添加:

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
   $_SERVER['HTTPS'] = 'on';
}

if ( !isset( $_SERVER['HTTPS'] ) ) {
    $_SERVER['HTTPS'] = 'on';
}

freebsd-wordpress-varnish-hitch-3.png
7.可以安装wordpress插件,如Proxy Cache来管理缓存
freebsd-wordpress-varnish-hitch-4.png

参考:

标签: varnish

添加新评论