首先对标题进行解释: OpenResty 现行最新版本为 1.13.6.1(with Nginx mainline 1.13.6),这就是为什么标题强调自定义 Nginx 的原因,就是要不使用 OpenResty 内置的 Nginx 而是由我们自己选择和一并编译整合。
而标题中提到的默认环境,也就是 OpenResty 环境的默认安装(除 Nginx 外)。
替换 Nginx
首先下载 OpenResty 1.13.6.1 到本地:
wget https://openresty.org/download/openresty-1.13.6.1.tar.gz && tar -zxf openresty-1.13.6.1.tar.gz cd openresty-1.13.6.1
进入 OpenResty 目录后,在 /bundle/ 路径下你会看到有个叫 nginx-1.13.6
的文件夹,是的,把这个文件里面的内容换成你想使用的 Nginx 版本。
安装 OpenResty
然后就可以开始安装了。安装分为两个部分:自定义 Nginx 的安装和 OpenResty 默认环境的安装。其中 Nginx 的安装和不使用 OpenResty 安装时是一样的,而 OpenResty 的安装只需要 ./configure
就能实现默认环境安装。
这里引用下官网的安装说明(via):
cd openresty-VERSION/ ./configure make make install
那么在使用自定义 Nginx 后,安装过程就是这样的:
# 进入 OpenResty 根目录 # 需要注意的是 Nginx 放在它的子目录内 cd openresty-1.13.6.1 # 省略 Nginx 的编译参数 # 这里 configure 只需要写入你的 Nginx 的编译参数 ./configure / ... / ... / ... # 防止 Werror=strict-aliasing 报错 export CFLAGS="-Wno-strict-aliasing" # 然后就是 make 了 make -j2 make install
顺便补充一句,本博客现行 OpenResty 环境就采用上述安装方式,使用的 Nginx 版本为 mainline 1.13.9 并自行修改过。
转载请注明:逗比根据地 » OpenResty 默认环境 + 自定义 Nginx 的安装