The runtime environment for Apache APISIX requires Nginx and etcd.
So before installation, please follow the different operating systems install Dependencies.
You can install Apache APISIX in a variety of ways, including source code packages, Docker, and Luarocks.
You need to download the Apache source release first:
$ mkdir apisix-2.4 $ wget https://downloads.apache.org/apisix/2.4/apache-apisix-2.4-src.tgz $ tar zxvf apache-apisix-2.4-src.tgz -C apisix-2.4
Install the Lua libraries that the runtime depends on:
cd apache-apisix-2.4 make deps
sudo yum install -y https://github.com/apache/apisix/releases/download/2.4/apisix-2.4-0.x86_64.rpm
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
sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/apache/apisix/master/utils/install-apisix.sh)"
Install the specified version via Luarocks:
# Install version 2.4 sudo luarocks install --lua-dir=/path/openresty/luajit apisix 2.4 # old luarocks not support the `lua-dir` parameter, you can remove this option sudo luarocks install apisix 2.4
We can start the APISIX server by command make run
in APISIX home folder, or we can stop APISIX server by command make stop
.
# init nginx config file and etcd $ make init # start APISIX server $ make run # stop APISIX server $ make stop # more actions find by `help` $ make help Makefile rules: 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 verify: Verify the configuration of apisix server clean: Remove generated files reload: Reload the apisix server install: Install the apisix (only for luarocks) test: Run the test case license-check: Check Lua source code for Apache License
Environment variable can be used to configure APISIX. Please take a look at conf/config.yaml
to see how to do it.
cpanminus
firsttest-nginx
's dependencies via cpanm
::sudo cpanm --notest Test::Nginx IPC::Run > build.log 2>&1 || (cat build.log && exit 1)
git clone https://github.com/iresty/test-nginx.git
. Note that we should use our fork.test-nginx
library with perl's prove
command and run the test cases in the /t
directory:export PERL5LIB=.:$PERL5LIB
make test
TEST_NGINX_BINARY=/usr/local/bin/openresty prove -Itest-nginx/lib -r t
Set Nginx Path
Error unknown directive "lua_package_path" in /API_ASPIX/apisix/t/servroot/conf/nginx.conf
make sure to set openresty as default nginx. And export the path as below.Run Individual Test Cases
Changes the apisix.admin_key
in the file conf/config.yaml
and restart the service. Here is an example:
apisix: # ... ... admin_key - name: "admin" key: abcdefghabcdefgh role: admin
When calling the Admin API, key
can be used as a token.
$ curl http://127.0.0.1:9080/apisix/admin/routes?api_key=abcdefghabcdefgh -i HTTP/1.1 200 OK Date: Fri, 28 Feb 2020 07:48:04 GMT Content-Type: text/plain ... ... {"node":{...},"action":"get"} $ curl http://127.0.0.1:9080/apisix/admin/routes?api_key=abcdefghabcdefgh-invalid -i HTTP/1.1 401 Unauthorized Date: Fri, 28 Feb 2020 08:17:58 GMT Content-Type: text/html ... ... {"node":{...},"action":"get"}