在上一篇文章 OpenResty 默认环境 + 自定义 Nginx 的安装 已介绍过 OpenResty 的大致安装方式。遂本文直接介绍现本博客 OpenResty 环境安装的过程记录。
Nginx 部分
首先将编译安装 Nginx 的所需素材准备好:
# 本博客环境的所在路径 mkdir -p /home/openresty-installation cd /home/openresty-installation # 下载所需 apt-get install -y git # 编译所需 apt-get install -y build-essential cmake clang # 最新版 pcre 8.42 # 注意 pcre2 没有对 Nginx 的支持 wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz && tar -zxf pcre-8.42.tar.gz cd pcre-8.42 && ./configure && cd .. # cloudflare 维护的 zlib git clone https://github.com/cloudflare/zlib.git zlib-cloudflare cd zlib-cloudflare && ./configure && cd .. # 本博客使用 BoringSSL 作为加密库 # https://sometimesnaive.org/article/64 # 本博客使用 OpenResty 环境 # https://sometimesnaive.org/article/70
整理出 Nginx 部分的编译参数:
./configure / --prefix=/home/openresty / --with-pcre=/home/openresty-installation/pcre-8.42 --with-pcre-jit / --with-zlib=/home/openresty-installation/zlib-cloudflare / --with-openssl=/home/openresty-installation/boringssl / --with-http_ssl_module --with-http_v2_module / ... / (更多拓展在此不做阐述,根据个人需求自行抉择)
需要注意的是,以上参数只是先准备好,并不是要现在就编译三连。这些参数只是先列出来准备好,在后面 OpenResty 路径下操作时带上这些参数。
OpenResty 部分
接下来就是准备 OpenResty 的部分,正如上篇文章所述,直接一个 ./configure
就够了,不需要额外指定什么参数。
先把 OpenResty 准备好。这里要注意的是,我用 Nginx 1.15.5 替换掉 OpenResty 原本提供的 Nginx 1.13.6 版本:
# 下载 OpenResty wget https://openresty.org/download/openresty-1.13.6.2.tar.gz && tar -zxf openresty-1.13.6.2.tar.gz # 替换 Nginx rm -rf /home/openresty-installation/openresty-1.13.6.2/bundle/nginx-1.13.6 cp -r /home/openresty-installation/nginx-1.15.5 /home/openresty-installation/openresty-1.13.6.2/bundle/nginx-1.13.6
然后在 OpenResty 部分,需要注意的是我另外编译 LuaJit 2.1 并使用 --with-luajit=/home/openresty-installation/luajit-2.1/makeinstalled
参数导入过来,而没有使用 OpenResty 默认的版本。关于我的 LuaJit 的编译,我记述于 这篇文章。
然后就可以开始编译三连了,记得把上面列出的 Nginx 编译参数也带过来:
# 进入 OpenResty 目录 cd /home/openresty-installation/openresty-1.13.6.2 # 把 Nginx 编译参数也带过来 ./configure / --prefix=/home/openresty / --with-pcre=/home/openresty-installation/pcre-8.42 --with-pcre-jit / --with-zlib=/home/openresty-installation/zlib-cloudflare / --with-openssl=/home/openresty-installation/boringssl / --with-http_ssl_module --with-http_v2_module / ... / (更多拓展在此不做阐述,根据个人需求自行抉择) --with-luajit=/home/openresty-installation/luajit-2.1/makeinstalled # make 两连 make make install
然后整个 OpenResty 环境就安装到 /home/openresty
路径下了。
转载请注明:逗比根据地 » 本博客 OpenResty 环境安装