更新至 OpenResty 1.17.8.2 版本

依赖

编译 zlib

zlib 数据压缩库。

安装 zlib 1.2.11:

# 下载
wget https://zlib.net/zlib-1.2.11.tar.gz
tar zxf zlib-1.2.11.tar.gz

# 安装
cd zlib-1.2.11
./configure --prefix=/usr/local/openresty/zlib
make CFLAGS='-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -g3' \
	SFLAGS='-O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -g3' \
	> /dev/stderr
make install

# 清理
rm -rf /usr/local/openresty/zlib/share/
rm -f /usr/local/openresty/zlib/lib/*.la
rm -rf /usr/local/openresty/zlib/lib/pkgconfig/

zlib 安装至 /usr/local/openresty/zlib 目录。

编译 PCRE

PCRE (Perl Compatible Regular Expressions)兼容 Perl 5 的正则表达式库。

安装 PCRE 8.44:

# 下载
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
tar zxf pcre-8.44.tar.gz

# 安装
cd pcre-8.44
./configure \
    --prefix=/usr/local/openresty/pcre \
    --libdir=/usr/local/openresty/pcre/lib \
    --disable-cpp \
    --enable-jit \
    --enable-utf \
    --enable-unicode-properties
make V=1 > /dev/stderr
make install

# 清理
rm -rf /usr/local/openresty/pcre/bin
rm -rf /usr/local/openresty/pcre/share
rm -f /usr/local/openresty/pcre/lib/*.la
rm -f /usr/local/openresty/pcre/lib/*pcrecpp*
rm -f /usr/local/openresty/pcre/lib/*pcreposix*
rm -rf /usr/local/openresty/pcre/lib/pkgconfig

PCRE 安装至 /usr/local/openresty/pcre 目录。

编译 OpenSSL

OpenSSL SSL/TSL 工具集。

安装 OpenSSL 1.1.1g:

# 下载
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
wget https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.1.1f-sess_set_get_cb_yield.patch --no-check-certificate
tar zxf openssl-1.1.1g.tar.gz

# 安装
cd openssl-1.1.1g
patch -p1 < ../openssl-1.1.1f-sess_set_get_cb_yield.patch
./config \
    no-threads shared zlib -g \
    enable-camellia enable-seed enable-rfc3779 enable-cms enable-md2 enable-rc5 enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method \
    --prefix=/usr/local/openresty/openssl111 \
    --libdir=lib \
    -I/usr/local/openresty/zlib/include \
    -L/usr/local/openresty/zlib/lib \
    -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/openssl111/lib
make
make install_sw

# 清理
rm -rf /usr/local/openresty/openssl111/bin/c_rehash
rm -rf /usr/local/openresty/openssl111/lib/pkgconfig
rm -rf /usr/local/openresty/openssl111/misc

OpenSSL 安装至 /usr/local/openresty/openssl111 目录。

编译 OpenResty

# 下载
wget https://openresty.org/download/openresty-1.17.8.2.tar.gz
tar zxf openresty-1.17.8.2.tar.gz

# 安装
cd openresty-1.17.8.2
./configure \
    --prefix="/usr/local/openresty" \
    --with-cc='gcc' \
    --with-cc-opt="-DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include" \
    --with-ld-opt="-L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib" \
    --with-pcre-jit \
    --without-http_rds_json_module \
    --without-http_rds_csv_module \
    --without-lua_rds_parser \
    --with-stream \
    --with-stream_ssl_module \
    --with-stream_ssl_preread_module \
    --with-http_v2_module \
    --without-mail_pop3_module \
    --without-mail_imap_module \
    --without-mail_smtp_module \
    --with-http_stub_status_module \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_auth_request_module \
    --with-http_secure_link_module \
    --with-http_random_index_module \
    --with-http_gzip_static_module \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_gunzip_module \
    --with-threads \
    --with-compat \
    --with-luajit-xcflags='-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'
make
make install

# 清理
rm -rf /usr/local/openresty/luajit/share/man
rm -rf /usr/local/openresty/luajit/lib/libluajit-5.1.a

参考