OpenResty 源码编译安装脚本:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
#!/bin/bash
set -e

zlib_version=1.2.13
pcre_version=8.45
openssl_version=1.1.1t
openresty_version=1.21.4.1

openssl_prefix=/usr/local/openresty/openssl111
zlib_prefix=/usr/local/openresty/zlib
pcre_prefix=/usr/local/openresty/pcre
openresty_prefix=/usr/local/openresty


yum install -y ccache bzip2
mkdir openresty-source
cd openresty-source

wget https://www.zlib.net/zlib-${zlib_version}.tar.xz
wget https://sourceforge.net/projects/pcre/files/pcre/${pcre_version}/pcre-${pcre_version}.tar.bz2
wget https://www.openssl.org/source/openssl-${openssl_version}.tar.gz
wget https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.1.1f-sess_set_get_cb_yield.patch
wget https://openresty.org/download/openresty-${openresty_version}.tar.gz


tar -xJf zlib-1.2.13.tar.xz
cd zlib-${zlib_version}
./configure --prefix=${zlib_prefix}
make -j`nproc` CFLAGS='-O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -g3' \
    SFLAGS='-O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -g3' \
    > /dev/stderr
make install
cd ..


tar -xjf pcre-${pcre_version}.tar.bz2
cd pcre-${pcre_version}
export CC="ccache gcc -fdiagnostics-color=always"
./configure \
  --prefix=${pcre_prefix} \
  --libdir=${pcre_prefix}/lib \
  --disable-cpp \
  --enable-jit \
  --enable-utf \
  --enable-unicode-properties
make -j`nproc` V=1 > /dev/stderr
make install
cd ..

tar zxf openssl-${openssl_version}.tar.gz
cd openssl-${openssl_version}/
patch -p1 <  ../openssl-1.1.1f-sess_set_get_cb_yield.patch

./config \
    shared zlib -g3 \
    enable-camellia enable-seed enable-rfc3779 \
    enable-cms enable-md2 enable-rc5 \
    enable-weak-ssl-ciphers \
    enable-ssl3 enable-ssl3-method \
    --prefix=${openssl_prefix} \
    --libdir=lib \
    -I${zlib_prefix}/include \
    -L${zlib_prefix}/lib \
    -Wl,-rpath,${zlib_prefix}/lib:${openssl_prefix}/lib

make CC='ccache gcc -fdiagnostics-color=always' -j`nproc`
make install
cd ..


tar zxf openresty-${openresty_version}.tar.gz
cd openresty-${openresty_version}
./configure \
--prefix="${openresty_prefix}" \
--with-cc='ccache gcc -fdiagnostics-color=always' \
--with-cc-opt="-DNGX_LUA_ABORT_AT_PANIC -I${zlib_prefix}/include -I${pcre_prefix}/include -I${openssl_prefix}/include" \
--with-ld-opt="-L${zlib_prefix}/lib -L${pcre_prefix}/lib -L${openssl_prefix}/lib -Wl,-rpath,${zlib_prefix}/lib:${pcre_prefix}/lib:${openssl_prefix}/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' \
-j`nproc`

make -j`nproc`
make install
cd ..

参考

https://github.com/openresty/openresty-packaging/blob/master/rpm/SPECS/openresty.spec