Skip to content

Commit

Permalink
chore: sync install-dependencies.md & polish it (#3467)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander authored Feb 2, 2021
1 parent 0b22938 commit b033a75
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.
14 changes: 5 additions & 9 deletions doc/install-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@

- If you want use Tengine instead of OpenResty, please take a look at this installation step script [Install Tengine at Ubuntu](../.travis/linux_tengine_runner.sh).

- By default Apache APISIX runs with LuaJIT of OpenResty 1.19 (priority) or Lua 5.1. If you run in to an issue `luajit: lj_asm_x86.h:2819: asm_loop_fixup: Assertion '((intptr_t)target & 15) == 0' failed`, it is caused by to the compatibility of OpenResty version. OpenResty 1.19 is recommended, please take a look at this installation step script [linux-install-openresty](../utils/linux-install-openresty.sh).
- 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.

# CentOS 7

```shell
# install epel, `luarocks` need it.
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm

# install etcd
wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz
tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
Expand All @@ -55,13 +53,11 @@ 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 lua-devel openresty-openssl-devel
sudo yum install -y openresty curl git gcc openresty-openssl-devel

# install LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | sudo bash -

# configure

# start etcd server
nohup etcd &
```
Expand All @@ -80,7 +76,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 lua-devel openresty-openssl-devel
sudo yum install -y openresty curl git gcc openresty-openssl-devel

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

- 如果你要想使用 Tengine 替代 OpenResty,请参考 [Install Tengine at Ubuntu](../../.travis/linux_tengine_runner.sh)

- Apache APISIX 运行默认使用 OpenResty 1.19 内置的 LuaJIT(优先推荐)或 Lua 5.1。若运行过程中出现问题 `luajit: lj_asm_x86.h:2819: asm_loop_fixup: Assertion '((intptr_t)target & 15) == 0' failed`,是因 OpenResty 版本兼容性问题,建议更换 OpenResty 版本为 1.19,请参考 [linux-install-openresty](../../utils/linux-install-openresty.sh)
- 如果是 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 的相一致。

# CentOS 7

```shell
# 安装 epel, `luarocks` 需要它
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm

# 安装 etcd
wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz
tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
Expand All @@ -54,7 +52,10 @@ 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 luarocks lua-devel
sudo yum install -y openresty curl git gcc openresty-openssl-devel

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | sudo bash -

# 开启 etcd server
nohup etcd &
Expand All @@ -74,7 +75,10 @@ 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 luarocks lua-devel
sudo yum install -y openresty curl git gcc openresty-openssl-devel

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | sudo bash -

# 开启 etcd server
nohup etcd &
Expand All @@ -97,7 +101,10 @@ 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 luarocks
sudo apt-get install -y git openresty curl openresty-openssl-dev

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | sudo bash -

# 开启 etcd server
nohup etcd &
Expand Down Expand Up @@ -125,7 +132,10 @@ 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 luarocks
sudo apt-get install -y git openresty curl make openresty-openssl-dev

# 安装 LuaRocks
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | sudo bash -

# 开启 etcd server
nohup etcd &
Expand Down
13 changes: 4 additions & 9 deletions utils/centos7-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ install_dependencies() {
yum install -y wget tar gcc automake autoconf libtool make unzip \
curl git which sudo

# install epel and luarocks
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum install -y lua-devel

./apisix/utils/linux-install-luarocks.sh

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

# install luarocks
./apisix/utils/linux-install-luarocks.sh

# install etcdctl
wget https://github.com/etcd-io/etcd/releases/download/v3.4.0/etcd-v3.4.0-linux-amd64.tar.gz
Expand Down
14 changes: 13 additions & 1 deletion utils/linux-install-luarocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ fi
wget https://github.com/luarocks/luarocks/archive/v3.4.0.tar.gz
tar -xf v3.4.0.tar.gz
cd luarocks-3.4.0 || exit
./configure --prefix=/usr > build.log 2>&1 || (cat build.log && exit 1)

OR_BIN="$OPENRESTY_PREFIX/bin/openresty"
OR_VER=$($OR_BIN -v 2>&1 | awk -F '/' '{print $2}' | awk -F '.' '{print $1"."$2}')
if [[ -e $OR_BIN && "$OR_VER" == 1.19 ]]; then
WITH_LUA_OPT="--with-lua=${OPENRESTY_PREFIX}/luajit"
else
# For old version OpenResty, we still need to install LuaRocks with Lua
WITH_LUA_OPT=
fi

./configure --prefix=/usr $WITH_LUA_OPT \
> build.log 2>&1 || (cat build.log && exit 1)

make build > build.log 2>&1 || (cat build.log && exit 1)
make install > build.log 2>&1 || (cat build.log && exit 1)
cd .. || exit
Expand Down
2 changes: 1 addition & 1 deletion 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 lua5.1 liblua5.1-0-dev openresty-openssl-debug-dev
sudo apt-get install openresty-openssl-debug-dev
exit 0
fi

Expand Down

0 comments on commit b033a75

Please sign in to comment.