2019-10-31 09:27:28 +08:00
|
|
|
|
<!--
|
|
|
|
|
#
|
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
#
|
|
|
|
|
-->
|
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
# Build Apache APISIX
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
## 1. Install dependencies
|
|
|
|
|
The runtime environment for Apache APISIX requires Nginx and etcd.
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
So before installation, please follow the different operating systems [install Dependencies](install-dependencies.md).
|
2019-09-16 21:40:39 +08:00
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
## 2. Install Apache APISIX
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
You can install Apache APISIX in a variety of ways, including source code packages, Docker, and Luarocks.
|
|
|
|
|
|
2019-11-27 21:55:56 +08:00
|
|
|
|
### Installation via source release
|
2019-09-12 10:56:47 +08:00
|
|
|
|
|
2019-11-27 21:55:56 +08:00
|
|
|
|
You need to download the Apache source release first:
|
2019-11-25 13:09:32 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2020-01-15 11:56:50 +08:00
|
|
|
|
wget http://www.apache.org/dist/incubator/apisix/1.0/apache-apisix-1.0-incubating-src.tar.gz
|
|
|
|
|
tar zxvf apache-apisix-1.0-incubating-src.tar.gz
|
2019-11-25 13:09:32 +08:00
|
|
|
|
```
|
2019-09-12 10:56:47 +08:00
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
Install the Lua libraries that the runtime depends on:
|
|
|
|
|
```shell
|
2020-01-15 11:56:50 +08:00
|
|
|
|
cd apache-apisix-1.0-incubating
|
2019-11-12 16:38:23 +08:00
|
|
|
|
make deps
|
2019-07-18 16:09:30 +08:00
|
|
|
|
```
|
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
### Installation via RPM package (CentOS 7)
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
```shell
|
2020-02-06 11:33:56 +08:00
|
|
|
|
sudo yum install -y https://github.com/apache/incubator-apisix/releases/download/1.0/apisix-1.0-0.el7.noarch.rpm
|
2019-11-25 13:09:32 +08:00
|
|
|
|
```
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
### Installation via Luarocks (macOS not supported)
|
|
|
|
|
|
|
|
|
|
Execute the following command in the terminal to complete the installation of APISIX (only recommended for developers):
|
|
|
|
|
|
|
|
|
|
> Install the code for the master branch via a script
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2019-11-25 13:09:32 +08:00
|
|
|
|
sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/apache/incubator-apisix/master/utils/install-apisix.sh)"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
> Install the specified version via Luarocks:
|
|
|
|
|
|
|
|
|
|
```shell
|
2020-01-15 11:56:50 +08:00
|
|
|
|
# Install version 1.0
|
|
|
|
|
sudo luarocks install --lua-dir=/path/openresty/luajit apisix 1.0
|
2019-11-25 13:09:32 +08:00
|
|
|
|
|
|
|
|
|
# old luarocks not support the `lua-dir` parameter, you can remove this option
|
2020-01-15 11:56:50 +08:00
|
|
|
|
sudo luarocks install apisix 1.0
|
2019-07-18 16:09:30 +08:00
|
|
|
|
```
|
|
|
|
|
|
2019-09-16 21:40:39 +08:00
|
|
|
|
## Manage (start/stop) APISIX Server
|
|
|
|
|
|
2019-11-25 13:09:32 +08:00
|
|
|
|
We can start the APISIX server by command `make run` in APISIX home folder,
|
2019-09-16 21:40:39 +08:00
|
|
|
|
or we can stop APISIX server by command `make stop`.
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
2019-09-16 21:40:39 +08:00
|
|
|
|
# init nginx config file and etcd
|
|
|
|
|
$ make init
|
|
|
|
|
|
|
|
|
|
# start APISIX server
|
|
|
|
|
$ make run
|
|
|
|
|
|
|
|
|
|
# stop APISIX server
|
|
|
|
|
$ make stop
|
|
|
|
|
|
|
|
|
|
# more actions find by `help`
|
2019-07-18 16:09:30 +08:00
|
|
|
|
$ make help
|
|
|
|
|
Makefile rules:
|
|
|
|
|
|
2019-11-21 09:23:16 +08:00
|
|
|
|
help: Show Makefile rules.
|
|
|
|
|
deps: Installation dependencies
|
|
|
|
|
utils: Installation tools
|
|
|
|
|
lint: Lint Lua source code
|
|
|
|
|
init: Initialize the runtime environment
|
|
|
|
|
run: Start the apisix server
|
|
|
|
|
stop: Stop the apisix server
|
|
|
|
|
clean: Remove generated files
|
|
|
|
|
reload: Reload the apisix server
|
|
|
|
|
install: Install the apisix
|
|
|
|
|
test: Run the test case
|
|
|
|
|
license-check: Check lua souce code for Apache License
|
2019-07-18 16:09:30 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Test
|
|
|
|
|
|
2019-10-22 10:21:37 +08:00
|
|
|
|
1. Install perl's package manager `cpanminus` first
|
|
|
|
|
2. Then install `test-gninx` via `cpanm`::`sudo cpanm --notest Test::Nginx IPC::Run > build.log 2>&1 || (cat build.log && exit 1)`
|
2019-10-30 10:43:37 +08:00
|
|
|
|
3. Clone source code:`git clone https://github.com/openresty/test-nginx.git`;
|
|
|
|
|
4. Load the `test-nginx` library with perl's `prove` command and run the test cases in the `/t` directory:
|
|
|
|
|
* Run the test cases: `prove -Itest-nginx/lib -r t`
|
|
|
|
|
* To set the path of nginx to run the test cases: `TEST_NGINX_BINARY=/usr/local/bin/openresty prove -Itest-nginx/lib -r t`
|