Skip to content

Commit

Permalink
fix: use openssl111 in openresty dir in precedence (#3603)
Browse files Browse the repository at this point in the history
close #3600
  • Loading branch information
tokers authored Feb 20, 2021
1 parent 7dde426 commit bee574f
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fuzzing-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"
sudo apt-get update
sudo apt-get install -y git openresty curl openresty-openssl-dev unzip make gcc
sudo apt-get install -y git openresty curl openresty-openssl111-dev unzip make gcc
./utils/linux-install-luarocks.sh
make deps
Expand Down
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ UNAME ?= $(shell uname)
OR_EXEC ?= $(shell which openresty || which nginx)
LUAROCKS_VER ?= $(shell luarocks --version | grep -E -o "luarocks [0-9]+.")
OR_PREFIX ?= $(shell $(OR_EXEC) -V 2>&1 | grep -Eo 'prefix=(.*)/nginx\s+' | grep -Eo '/.*/')
OPENSSL_PREFIX ?= $(addprefix $(OR_PREFIX), openssl)

# OpenResty 1.17.8 or higher version uses openssl111 as the openssl dirname.
ifeq ($(shell test -d $(addprefix $(OR_PREFIX), openssl111) && echo -n yes), yes)
OPENSSL_PREFIX=$(addprefix $(OR_PREFIX), openssl111)
endif

SHELL := /bin/bash -o pipefail

Expand Down Expand Up @@ -57,18 +63,18 @@ deps: default
ifeq ($(LUAROCKS_VER),luarocks 3.)
mkdir -p ~/.luarocks
ifeq ($(shell whoami),root)
luarocks config variables.OPENSSL_LIBDIR $(addprefix $(OR_PREFIX), openssl/lib)
luarocks config variables.OPENSSL_INCDIR $(addprefix $(OR_PREFIX), openssl/include)
luarocks config variables.OPENSSL_LIBDIR $(addprefix $(OPENSSL_PREFIX), /lib)
luarocks config variables.OPENSSL_INCDIR $(addprefix $(OPENSSL_PREFIX), /include)
else
luarocks config --local variables.OPENSSL_LIBDIR $(addprefix $(OR_PREFIX), openssl/lib)
luarocks config --local variables.OPENSSL_INCDIR $(addprefix $(OR_PREFIX), openssl/include)
luarocks config --local variables.OPENSSL_LIBDIR $(addprefix $(OPENSSL_PREFIX), /lib)
luarocks config --local variables.OPENSSL_INCDIR $(addprefix $(OPENSSL_PREFIX), /include)
endif
luarocks install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local
else
@echo "WARN: You're not using LuaRocks 3.x, please add the following items to your LuaRocks config file:"
@echo "variables = {"
@echo " OPENSSL_LIBDIR=$(addprefix $(OR_PREFIX), openssl/lib)"
@echo " OPENSSL_INCDIR=$(addprefix $(OR_PREFIX), openssl/include)"
@echo " OPENSSL_LIBDIR=$(addprefix $(OPENSSL_PREFIX), /lib)"
@echo " OPENSSL_INCDIR=$(addprefix $(OPENSSL_PREFIX), /include)"
@echo "}"
luarocks install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local
endif
Expand Down
12 changes: 7 additions & 5 deletions doc/install-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@

- If it is OpenResty 1.19, APISIX will use OpenResty's built-in LuaJIT to run `bin/apisix`; otherwise it will use Lua 5.1. If you encounter `luajit: lj_asm_x86.h:2819: asm_loop_ fixup: Assertion '((intptr_t)target & 15) == 0' failed`, this is a problem with the low version of OpenResty's built-in LuaJIT under certain compilation conditions.

- On some platforms, installing LuaRocks via the package manager will cause Lua to be upgraded to Lua 5.3, so we recommend installing LuaRocks via source code. if you install OpenResty and its OpenSSL develop library (openresty-openssl-devel for rpm and openresty-openssl-dev for deb) via the official repository, then [we provide a script for automatic installation](../utils/linux-install-luarocks.sh). If you compile OpenResty yourself, you can refer to the above script and change the path in it. If you don't specify the OpenSSL library path when you compile, you don't need to configure the OpenSSL variables in LuaRocks, because the system's OpenSSL is used by default. If the OpenSSL library is specified at compile time, then you need to ensure that LuaRocks' OpenSSL configuration is consistent with OpenResty's.
- On some platforms, installing LuaRocks via the package manager will cause Lua to be upgraded to Lua 5.3, so we recommend installing LuaRocks via source code. if you install OpenResty and its OpenSSL develop library (openresty-openssl111-devel for rpm and openresty-openssl111-dev for deb) via the official repository, then [we provide a script for automatic installation](../utils/linux-install-luarocks.sh). If you compile OpenResty yourself, you can refer to the above script and change the path in it. If you don't specify the OpenSSL library path when you compile, you don't need to configure the OpenSSL variables in LuaRocks, because the system's OpenSSL is used by default. If the OpenSSL library is specified at compile time, then you need to ensure that LuaRocks' OpenSSL configuration is consistent with OpenResty's.

- WARNING: If you are using OpenResty which is older than `1.17.8`, please installing openresty-openss-devel instead of openresty-openssl111-devel.

# CentOS 7

Expand All @@ -53,7 +55,7 @@ sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

# install OpenResty and some compilation tools
sudo yum install -y openresty curl git gcc openresty-openssl-devel unzip
sudo yum install -y openresty curl git gcc openresty-openssl111-devel unzip

# install LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand All @@ -76,7 +78,7 @@ tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
sudo cp -a etcd etcdctl /usr/bin/

# install OpenResty and some compilation tools
sudo yum install -y openresty curl git gcc openresty-openssl-devel
sudo yum install -y openresty curl git gcc openresty-openssl111-devel

# install LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand All @@ -102,7 +104,7 @@ tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
sudo cp -a etcd etcdctl /usr/bin/

# install OpenResty and some compilation tools
sudo apt-get install -y git openresty curl openresty-openssl-dev
sudo apt-get install -y git openresty curl openresty-openssl111-dev

# install LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand Down Expand Up @@ -133,7 +135,7 @@ tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
sudo cp -a etcd etcdctl /usr/bin/

# install OpenResty and some compilation tools
sudo apt-get install -y git openresty curl make openresty-openssl-dev
sudo apt-get install -y git openresty curl make openresty-openssl111-dev

# install LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand Down
12 changes: 7 additions & 5 deletions doc/zh-cn/install-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@

- 如果是 OpenResty 1.19,APISIX 会使用 OpenResty 内置的 LuaJIT 来运行 `bin/apisix`;否则会使用 Lua 5.1。如果运行过程中遇到 `luajit: lj_asm_x86.h:2819: asm_loop_fixup: Assertion '((intptr_t)target & 15) == 0' failed`,这是低版本 OpenResty 内置的 LuaJIT 在特定编译条件下的问题。

- 在某些平台上,通过包管理器安装 LuaRocks 会导致 Lua 被升级为 Lua 5.3,所以我们建议通过源代码的方式安装 LuaRocks。如果你通过官方仓库安装 OpenResty 和 OpenResty 的 OpenSSL 开发库(rpm 版本:openresty-openssl-devel,deb 版本:openresty-openssl-dev),那么 [我们提供了自动安装的脚本](../../utils/linux-install-luarocks.sh)。如果你是自己编译的 OpenResty,可以参考上述脚本并修改里面的路径。如果编译时没有指定 OpenSSL 库的路径,那么无需配置 LuaRocks 内跟 OpenSSL 相关的变量,因为默认都是用的系统自带的 OpenSSL。如果编译时指定了 OpenSSL 库,那么需要保证 LuaRocks 的 OpenSSL 配置跟 OpenResty 的相一致。
- 在某些平台上,通过包管理器安装 LuaRocks 会导致 Lua 被升级为 Lua 5.3,所以我们建议通过源代码的方式安装 LuaRocks。如果你通过官方仓库安装 OpenResty 和 OpenResty 的 OpenSSL 开发库(rpm 版本:openresty-openssl111-devel,deb 版本:openresty-openssl111-dev),那么 [我们提供了自动安装的脚本](../../utils/linux-install-luarocks.sh)。如果你是自己编译的 OpenResty,可以参考上述脚本并修改里面的路径。如果编译时没有指定 OpenSSL 库的路径,那么无需配置 LuaRocks 内跟 OpenSSL 相关的变量,因为默认都是用的系统自带的 OpenSSL。如果编译时指定了 OpenSSL 库,那么需要保证 LuaRocks 的 OpenSSL 配置跟 OpenResty 的相一致。

- 警告:如果你正在使用低于 `1.17.8` 的 OpenResty 版本,请安装 openresty-openssl-devel,而不是 openresty-openssl111-devel。

# CentOS 7

Expand All @@ -52,7 +54,7 @@ sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

# 安装 OpenResty 和 编译工具
sudo yum install -y openresty curl git gcc openresty-openssl-devel unzip
sudo yum install -y openresty curl git gcc openresty-openssl111-devel unzip

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand All @@ -75,7 +77,7 @@ tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
sudo cp -a etcd etcdctl /usr/bin/

# 安装 OpenResty 和 编译工具
sudo yum install -y openresty curl git gcc openresty-openssl-devel
sudo yum install -y openresty curl git gcc openresty-openssl111-devel

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand All @@ -101,7 +103,7 @@ tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
sudo cp -a etcd etcdctl /usr/bin/

# 安装 OpenResty 和 编译工具
sudo apt-get install -y git openresty curl openresty-openssl-dev
sudo apt-get install -y git openresty curl openresty-openssl111-dev

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand Down Expand Up @@ -132,7 +134,7 @@ tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
sudo cp -a etcd etcdctl /usr/bin/

# 安装 OpenResty 和 编译工具
sudo apt-get install -y git openresty curl make openresty-openssl-dev
sudo apt-get install -y git openresty curl make openresty-openssl111-dev

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
Expand Down
2 changes: 1 addition & 1 deletion utils/centos7-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install_dependencies() {

# install openresty
yum install -y yum-utils && yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
yum install -y openresty-debug openresty-openssl-debug-devel
yum install -y openresty-debug openresty-openssl111-debug-devel

# install luarocks
./utils/linux-install-luarocks.sh
Expand Down
11 changes: 9 additions & 2 deletions utils/linux-install-luarocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@ cd .. || exit
rm -rf luarocks-3.4.0

mkdir ~/.luarocks || true
luarocks config variables.OPENSSL_LIBDIR ${OPENRESTY_PREFIX}/openssl/lib
luarocks config variables.OPENSSL_INCDIR ${OPENRESTY_PREFIX}/openssl/include

# OpenResty 1.17.8 or higher version uses openssl111 as the openssl dirname.
OPENSSL_PREFIX=${OPENRESTY_PREFIX}/openssl
if [ -d ${OPENRESTY_PREFIX}/openssl111 ]; then
OPENSSL_PREFIX=${OPENRESTY_PREFIX}/openssl111
fi

luarocks config variables.OPENSSL_LIBDIR ${OPENSSL_PREFIX}/lib
luarocks config variables.OPENSSL_INCDIR ${OPENSSL_PREFIX}/include
10 changes: 8 additions & 2 deletions utils/linux-install-openresty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if [ "$OPENRESTY_VERSION" == "source" ]; then
make
sudo make install

sudo apt-get install openresty-openssl-debug-dev
sudo apt-get install openresty-openssl111-debug-dev
exit 0
fi

Expand All @@ -80,4 +80,10 @@ else
openresty="openresty-debug=$OPENRESTY_VERSION*"
fi

sudo apt-get install "$openresty" lua5.1 liblua5.1-0-dev openresty-openssl-debug-dev
sudo apt-get install "$openresty" lua5.1 liblua5.1-0-dev

if [ "$OPENRESTY_VERSION" == "1.15.8.2" ]; then
sudo apt-get install openresty-openssl-debug-dev
else
sudo apt-get install openresty-openssl111-debug-dev
fi

0 comments on commit bee574f

Please sign in to comment.