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.
sudo yum install -y https://github.com/apache/apisix/releases/download/2.5/apisix-2.5-0.x86_64.rpm
See https://hub.docker.com/r/apache/apisix
See https://github.com/apache/apisix-helm-chart
You need to download the Apache source release first:
$ mkdir apisix-2.5 $ wget https://downloads.apache.org/apisix/2.5/apache-apisix-2.5-src.tgz $ tar zxvf apache-apisix-2.5-src.tgz -C apisix-2.5
Install the Lua libraries that the runtime depends on:
cd apisix-2.5 make deps
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"}
Some features require you to build OpenResty with extra Nginx modules. If you need those features, you can build OpenResty with this build script.