From f24a24a6095646e34458ab09a222fdaed56c40c6 Mon Sep 17 00:00:00 2001 From: Yuansheng Date: Wed, 23 Oct 2019 02:16:18 -0400 Subject: [PATCH 1/6] doc: install steps. --- README.md | 16 ++++++++++++--- doc/install-dependencies.md | 41 ++++++++----------------------------- utils/install-apisix.sh | 7 ++++--- 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index ffe8d34adc08..2e00bb16eb03 100644 --- a/README.md +++ b/README.md @@ -114,13 +114,23 @@ We recommend that you use [luarocks](https://luarocks.org/) to install APISIX, a APISIX is installed by running the following commands in your terminal. -> via curl +> Gets the specified version via Luarock: + +```shell +# example to install apisix with version v0.8 +sudo luarocks install --lua-dir=/path/openresty/luajit apisix 0.8 + +# old luarocks may not support `lua-dir`, we can remove this option +sudo luarocks install apisix 0.8 +``` + +> Gets the latest version via curl ```shell sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/iresty/apisix/master/utils/install-apisix.sh)" ``` -> Manual inspection +> Gets the latest version with manual inspection It's a good idea to inspect the installation script from projects you don't know yet. You can do that by downloading the installation script first, looking through it so everything looks normal, then running it: @@ -129,7 +139,7 @@ curl -Lo install.sh https://raw.githubusercontent.com/iresty/apisix/master/utils sudo sh install.sh ``` -> installation complete +> Installation complete If all goes well, you will see the message like this: diff --git a/doc/install-dependencies.md b/doc/install-dependencies.md index e9b0ecf36038..94c97e004132 100644 --- a/doc/install-dependencies.md +++ b/doc/install-dependencies.md @@ -1,13 +1,13 @@ # Install Dependencies -* [CentOS 7](#centos-7) +* [CentOS 6 & 7](#centos-6--7) * [Ubuntu 16.04 & 18.04](#ubuntu-1604--1804) * [Debian 9 & 10](#debian-9--10) * [CentOS 6](#centos-6) * [Mac OSX](#mac-osx) -CentOS 7 -======== +CentOS 6 & 7 +============ ```shell # install epel, `luarocks` need it. @@ -19,8 +19,7 @@ sudo yum install yum-utils sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo # install openresty, etcd and some compilation tools -sudo yum install -y etcd openresty curl git automake autoconf \ - gcc pcre-devel libtool gcc-c++ luarocks lua-devel +sudo yum install -y etcd openresty curl git gcc luarocks lua-devel # start etcd server sudo service etcd start @@ -37,9 +36,7 @@ sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_releas sudo apt-get update # install openresty, etcd and some compilation tools -sudo apt-get install -y git etcd openresty curl luarocks\ - check libpcre3 libpcre3-dev libjemalloc-dev \ - libjemalloc1 build-essential libtool automake autoconf pkg-config +sudo apt-get install -y git etcd openresty curl luarocks # start etcd server sudo service etcd start @@ -54,6 +51,7 @@ sed -i 's|^deb http://deb.debian.org/debian|deb http://mirrors.huaweicloud.com/d sed -i 's|^deb http://security.debian.org/debian-security|deb http://mirrors.huaweicloud.com/debian-security|g' /etc/apt/sources.list apt update apt install wget gnupg -y + # add openresty source wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add - sudo apt-get -y install software-properties-common @@ -67,41 +65,18 @@ tar -xvf etcd-v3.3.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 \ - check libpcre3 libpcre3-dev libjemalloc-dev \ - build-essential libtool automake autoconf pkg-config - -# install luarocks -# (the version must > 3.0, --lua-dir was first introduced in the luarocks 3.0 release) - -wget https://luarocks.org/releases/luarocks-3.1.3.tar.gz -tar zxpf luarocks-3.1.3.tar.gz -cd luarocks-3.1.3 - -* Run `./configure --with-lua=/usr/local/openresty/luajit/`. (This will attempt to detect your installation of Lua. If you get any error messages, see the section "Customizing your settings", below.) -* Run `make build`. -* As superuser, run `make install`. -ln -s /usr/local/bin/luarocks /usr/bin/luarocks - +sudo apt-get install -y git openresty curl luarocks make # start etcd server nohup etcd & ``` -CentOS 6 -======== - -TODO - -Failed to compile `rapidjson`, but the CentOS 6 comes with a lower version, will support CentOS 6 later. - Mac OSX ======= ```shell # install openresty, etcd and some compilation tools -brew install autoconf automake check pkg-config pcre libtool openresty/brew/openresty etcd luarocks +brew install openresty/brew/openresty etcd luarocks curl git # start etcd server with v2 protocol etcd --enable-v2=true & diff --git a/utils/install-apisix.sh b/utils/install-apisix.sh index c66e818aec90..36fbc71c9701 100755 --- a/utils/install-apisix.sh +++ b/utils/install-apisix.sh @@ -4,6 +4,7 @@ set -ex OR_EXEC=`which openresty 2>&1` echo $OR_EXEC +APISIX_VER="https://raw.githubusercontent.com/iresty/apisix/master/rockspec/apisix-master-0.rockspec" # check the openresty exist CHECK_OR_EXIST=`echo $OR_EXEC | grep ": no openresty" | wc -l` @@ -25,13 +26,13 @@ echo $UNAME do_install() { if [ "$UNAME" == "Darwin" ]; then - luarocks install --lua-dir=$LUA_JIT_DIR apisix --tree=/usr/local/apisix/deps --local + luarocks install --lua-dir=$LUA_JIT_DIR $APISIX_VER --tree=/usr/local/apisix/deps --local elif [ "$LUAROCKS_VER" == 'luarocks 3.' ]; then - luarocks install --lua-dir=$LUA_JIT_DIR apisix --tree=/usr/local/apisix/deps --local + luarocks install --lua-dir=$LUA_JIT_DIR $APISIX_VER --tree=/usr/local/apisix/deps --local else - luarocks install apisix --tree=/usr/local/apisix/deps --local + luarocks install $APISIX_VER --tree=/usr/local/apisix/deps --local fi sudo rm -f /usr/local/bin/apisix From 6313bdfaf57f588e208f3e59dd04c1672067e325 Mon Sep 17 00:00:00 2001 From: Yuansheng Date: Wed, 23 Oct 2019 02:18:07 -0400 Subject: [PATCH 2/6] makefile: removed useless option. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index df636a08e842..8458c71b8ff7 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ dev: ifeq ($(UNAME),Darwin) luarocks install --lua-dir=$(LUA_JIT_DIR) rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local else ifneq ($(LUAROCKS_VER),'luarocks 3.') - WITHOUT_DASHBOARD=1 luarocks install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local + luarocks install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local else luarocks install --lua-dir=/usr/local/openresty/luajit rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local endif From 766edb5e0ab23651839c18b6bedbb893dc494c7b Mon Sep 17 00:00:00 2001 From: Yuansheng Date: Wed, 23 Oct 2019 02:20:28 -0400 Subject: [PATCH 3/6] doc: change. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2e00bb16eb03..090f74a4cd34 100644 --- a/README.md +++ b/README.md @@ -117,10 +117,10 @@ APISIX is installed by running the following commands in your terminal. > Gets the specified version via Luarock: ```shell -# example to install apisix with version v0.8 +# install apisix with version v0.8 sudo luarocks install --lua-dir=/path/openresty/luajit apisix 0.8 -# old luarocks may not support `lua-dir`, we can remove this option +# old luarocks may not support `lua-dir`, we can remove option `lua-dir` sudo luarocks install apisix 0.8 ``` From 46feb81a4994ea4b24bab11a59066318c49506ed Mon Sep 17 00:00:00 2001 From: Yuansheng Date: Wed, 23 Oct 2019 02:28:31 -0400 Subject: [PATCH 4/6] doc: Chinese ver. --- README.md | 24 ++++++++++++------------ README_CN.md | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 090f74a4cd34..995d474fca18 100644 --- a/README.md +++ b/README.md @@ -114,23 +114,13 @@ We recommend that you use [luarocks](https://luarocks.org/) to install APISIX, a APISIX is installed by running the following commands in your terminal. -> Gets the specified version via Luarock: - -```shell -# install apisix with version v0.8 -sudo luarocks install --lua-dir=/path/openresty/luajit apisix 0.8 - -# old luarocks may not support `lua-dir`, we can remove option `lua-dir` -sudo luarocks install apisix 0.8 -``` - -> Gets the latest version via curl +> Gets the master branch via curl ```shell sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/iresty/apisix/master/utils/install-apisix.sh)" ``` -> Gets the latest version with manual inspection +> Gets the master branch with manual inspection It's a good idea to inspect the installation script from projects you don't know yet. You can do that by downloading the installation script first, looking through it so everything looks normal, then running it: @@ -139,6 +129,16 @@ curl -Lo install.sh https://raw.githubusercontent.com/iresty/apisix/master/utils sudo sh install.sh ``` +> Gets the specified version via Luarock: + +```shell +# install apisix with version v0.8 +sudo luarocks install --lua-dir=/path/openresty/luajit apisix 0.8 + +# old luarocks may not support `lua-dir`, we can remove option `lua-dir` +sudo luarocks install apisix 0.8 +``` + > Installation complete If all goes well, you will see the message like this: diff --git a/README_CN.md b/README_CN.md index 0b1a56473172..d56caafebcfe 100644 --- a/README_CN.md +++ b/README_CN.md @@ -112,13 +112,13 @@ APISIX 是基于 [openresty](http://openresty.org/) 之上构建的, 配置数 在终端中执行下面命令完成 APISIX 的安装: -> 通过 curl +> 通过 curl 安装 master 分支 ```shell sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/iresty/apisix/master/utils/install-apisix.sh)" ``` -> 人工检查 +> 人工检查安装 master 分支 对你不熟悉项目的安装脚本做检查,是个非常好的习惯。可以先下载这个脚本,确保他都是正常脚本,然后运行: @@ -127,6 +127,16 @@ curl -Lo install.sh https://raw.githubusercontent.com/iresty/apisix/master/utils sudo sh install.sh ``` +> 通过 Luarocks 安装指定的版本: + +```shell +# 安装 apisix 的 0.8 版本 +sudo luarocks install --lua-dir=/path/openresty/luajit apisix 0.8 + +# 老版本 luarocks 可能不支持 `lua-dir` 参数,可以删除该选项 +sudo luarocks install apisix 0.8 +``` + > 安装完成 ``` From 5ebbdc5cef77bca48e8aa5920efcf98b81679920 Mon Sep 17 00:00:00 2001 From: Yuansheng Date: Wed, 23 Oct 2019 02:47:13 -0400 Subject: [PATCH 5/6] test: wait for a moment. --- t/plugin/node-status.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/t/plugin/node-status.t b/t/plugin/node-status.t index 8e8869fce870..d7a602e6204b 100644 --- a/t/plugin/node-status.t +++ b/t/plugin/node-status.t @@ -11,8 +11,21 @@ run_tests; __DATA__ === TEST 1: sanity +--- config +location /t { + content_by_lua_block { + ngx.sleep(0.5) + local t = require("lib.test_admin").test + local code, body, body_org = t('/apisix/status', ngx.HTTP_GET) + + if code >= 300 then + ngx.status = code + end + ngx.say(body_org) + } +} --- request -GET /apisix/status +GET /t --- response_body eval qr/"accepted":/ --- no_error_log From 2a223eeaef65f837236a10a629af2b24e49ae7d7 Mon Sep 17 00:00:00 2001 From: Yuansheng Date: Wed, 23 Oct 2019 03:01:13 -0400 Subject: [PATCH 6/6] doc: installation step for centos 6. --- doc/install-dependencies.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/install-dependencies.md b/doc/install-dependencies.md index 94c97e004132..32144d13ae3c 100644 --- a/doc/install-dependencies.md +++ b/doc/install-dependencies.md @@ -1,13 +1,33 @@ # Install Dependencies -* [CentOS 6 & 7](#centos-6--7) +* [CentOS 6](#centos-6) +* [CentOS 7](#centos-7) * [Ubuntu 16.04 & 18.04](#ubuntu-1604--1804) * [Debian 9 & 10](#debian-9--10) -* [CentOS 6](#centos-6) * [Mac OSX](#mac-osx) -CentOS 6 & 7 -============ +CentOS 6 +======== + +```shell +# add openresty source +sudo yum install yum-utils +sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo + +# install openresty, etcd and some compilation tools +sudo yum install -y openresty curl git gcc luarocks lua-devel make + +wget https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz +tar -xvf etcd-v3.3.13-linux-amd64.tar.gz && \ + cd etcd-v3.3.13-linux-amd64 && \ + sudo cp -a etcd etcdctl /usr/bin/ + +# start etcd server +nohup etcd & +``` + +CentOS 7 +======== ```shell # install epel, `luarocks` need it.