openresty编译
Aug. 4, 2016
依赖
-
ubuntu:
- sudo apt-get install systemtap-sdt-dev
- sudo apt-get install electric-fence 用于openssl调试
- apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essen 注意上面 如果pcre/openssl/zlib编译的化,就不需要安装相应的依赖
-
centos:
- yum install readline-devel pcre-devel openssl-devel gcc systemtap-sdt-devel
下载包
- wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
- wget http://zlib.net/zlib-1.2.8.tar.gz
- wget http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-8.39.tar.gz
- wget https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.0.2h-sess_set_get_cb_yield.patch
- wget https://openresty.org/download/openresty-1.9.15.1.tar.gz
- 全部解压到同一目录
先编译openssl
cd openssl-1.0.2h/ patch -b -p1 < ../openssl-1.0.2h-sess_set_get_cb_yield.patch ./config --prefix=/usr/local/openresty-debug/openssl no-threads no-asm shared -d -DPURIFY make depend make -j2 sudo make install
编译openresty
cd ../openresty-1.9.15.1/ ./configure --prefix=/usr/local/openresty-debug --with-debug --with-cc-opt="-I/usr/local/openresty-debug/openssl/include -O0" --with-ld-opt="-L/usr/local/openresty-debug/openssl/lib -Wl,-rpath,/usr/local/openresty-debug/openssl/lib" --with-zlib="../zlib-1.2.8" --with-pcre="../pcre-8.39" --with-pcre-opt="-DSUPPORT_UTF" --with-pcre-jit --without-http_rds_json_module --without-http_rds_csv_module --without-lua_rds_parser --with-ipv6 --with-stream --with-stream_ssl_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-file-aio --with-poll_module --with-luajit-xcflags='-DLUAJIT_ENABLE_LUA52COMPAT -O0' --with-dtrace-probes make sudo make install ldd /usr/local/openresty-debug/nginx/sbin/nginx ln -s到/esr/bin下。
注
- 以上,是调试版本
- 非调试版本 参见此url
https://github.com/openresty/openresty-packaging/tree/master/rpm/SPECS
- openssl配置 ./config --prefix=%{openssl_prefix} \ no-threads \ shared -g
- openresty配置 ./configure \ --with-cc-opt="-I%{orprefix}/openssl/include" \ --with-ld-opt="-L%{orprefix}/openssl/lib -Wl,-rpath,%{orprefix}/openssl/lib" \ --with-zlib=../zlib-%{zlib_version} \ --with-pcre=../pcre-%{pcre_version} \ --with-pcre-opt="-DSUPPORT_UTF" \ --with-pcre-jit \ --without-http_rds_json_module \ --without-http_rds_csv_module \ --without-lua_rds_parser \ --with-ipv6 \ --with-stream \ --with-stream_ssl_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-file-aio \ --with-luajit-xcflags='-DLUAJIT_ENABLE_LUA52COMPAT' \ --with-dtrace-probes
- 以上是编译版本,调试信息包含在其中。对于rpm包,参见https://github.com/openresty/openresty-packaging/tree/master/rpm/SPECS,调试信息包需要另生成。 对于deb包,暂时还没有。
- 对于官方构建的rpm,其config如下 configure arguments: --prefix=/usr/local/openresty-debug/nginx --with-debug --with-cc-opt='-DNGX_LUA_USE_ASSERT -DNGX_LUA_ABORT_AT_PANIC -O2 -I/usr/local/openresty-debug/openssl/include -O0' --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.59 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.30 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.05 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.5 --add-module=../ngx_lua_upstream-0.05 --add-module=../headers-more-nginx-module-0.30 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.17 --add-module=../redis2-nginx-module-0.13 --add-module=../redis-nginx-module-0.3.7 --with-ld-opt='-Wl,-rpath,/usr/local/openresty-debug/luajit/lib -L/usr/local/openresty-debug/openssl/lib -Wl,-rpath,/usr/local/openresty-debug/openssl/lib' --with-zlib=/builddir/build/BUILD/openresty-1.9.15.1/../zlib-1.2.8 --with-pcre=/builddir/build/BUILD/openresty-1.9.15.1/../pcre-8.39 --with-pcre-opt=-DSUPPORT_UTF --with-pcre-jit --with-ipv6 --with-stream --with-stream_ssl_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-file-aio --with-poll_module --with-dtrace-probes --with-http_ssl_module
- 在ubntu编译的openresty配置如下 /usr/local/openresty-debug/nginx/sbin/nginx -V nginx version: openresty/1.9.15.1 built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.1) built with OpenSSL 1.0.2h 3 May 2016 TLS SNI support enabled configure arguments: --prefix=/usr/local/openresty-debug/nginx --with-debug --with-cc-opt='-DNGX_LUA_USE_ASSERT -DNGX_LUA_ABORT_AT_PANIC -O2 -I/usr/local/openresty-debug/openssl/include -O0' --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.59 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.30 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.05 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.5 --add-module=../ngx_lua_upstream-0.05 --add-module=../headers-more-nginx-module-0.30 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.17 --add-module=../redis2-nginx-module-0.13 --add-module=../redis-nginx-module-0.3.7 --with-ld-opt='-Wl,-rpath,/usr/local/openresty-debug/luajit/lib -L/usr/local/openresty-debug/openssl/lib -Wl,-rpath,/usr/local/openresty-debug/openssl/lib' --with-zlib=/home/roidinev/objdev/openresty-1.9.15.1/../zlib-1.2.8 --with-pcre=/home/roidinev/objdev/openresty-1.9.15.1/../pcre-8.39 --with-pcre-opt=-DSUPPORT_UTF --with-pcre-jit --with-ipv6 --with-stream --with-stream_ssl_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-file-aio --with-poll_module --with-dtrace-probes --with-http_ssl_module