在Mac上部署Varnish
准备
在Mac OS X上安装Varnish是通过brew(即Homebrew)来实现的。当然,由于brew需要变易软件,所以你的系统还需要预先安装好Xcode编译工具。
xcode-select --installHomebrew是macOS平台上的包管理工具,可以用来移植(编译安装)大量的GNU/Linux软件。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"安装必要的编译工具:
brew install autoconf
brew install python
pip install docutils
brew install pcre
brew install pkg-config
brew install libmicrohttpd
brew install libtool编译和安装
./autogen.sh
./configure
make
sudo make install注意:在macOS上,默认的环境locale是
UTF-8,需要在编译时修改成Linux所使用的en_US.UTF-8,例如:
否则可能报错ValueError: unknown locale: UTF-8
当Varnish编译完成后,进入Varnish-Agent目录,然后执行以下命令:
启动Varnish和Varnish-Agnet
假设我们在后端启动一个简单的Python WEB服务
然后启动
varnish和varnish-agent:
Varnish的默认配置文件位于
/usr/local/etc/varnish/default.vcl
参考
How to speed up Apache with Varnish HTTP cache on Ubuntu 16.04 LTS - 在Ubuntu上配置Varnish
Last updated
Was this helpful?