cd /usr/local
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar -xvzf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap
gmake
gmake install
检查cmake是否安装成功:
$ cmake --version
cmake version 2.8.10.2
1.3 安装lua-zlib
(1)download
cd /usr/local
wget https://github.com/brimworks/lua-zlib/archive/master.zip
unzip lua-zlib-master.zip
(2)cmake
cd /usr/local/lua-zlib-master
cmake -DLUA_INCLUDE_DIR=/usr/local/openresty/luajit/include/luajit-2.1 -DLUA_LIBRARIES=/usr/local/openresty/luajit/lib -DUSE_LUAJIT=ON -DUSE_LUA=OFF
cp zlib.so /usr/local/openresty/lualib/zlib.so
2. zlib包使用
local zip = require(zlib)
local v,mv,pv=zip.version()
local str_data
-- ngx.log(ngx.INFO, "zip.version(): ", v, ", ", mv, ", ", pv)
local req_cotent_encoding = ngx.req.get_headers()["Content-Encoding"]
if req_cotent_encoding == "gzip" then
ngx.log(ngx.INFO, "req_cotent_encoding = gzip")
-- 解压缩
local inflate = zip.inflate()
str_data = inflate(data)
ngx.log(ngx.INFO, "raw data: ", data, ", after inflate str_data: ", str_data)
-- 压缩验证
--[[local deflate = zip.deflate()
str_data = deflate(data)
ngx.log(ngx.INFO, "raw data: ", data, ", after deflate str_data: ", str_data)]]--
ngx.log(ngx.INFO, "req_cotent_encoding ~= gzip")
str_data = data