2019-07-18 16:09:30 +08:00
|
|
|
|
# dev-manual
|
|
|
|
|
|
|
|
|
|
## Install APISIX in development environment
|
|
|
|
|
|
2019-10-22 16:35:44 +08:00
|
|
|
|
For different operating systems have different dependencies, see detail: [Install Dependencies](install-dependencies.md).
|
2019-09-16 21:40:39 +08:00
|
|
|
|
|
|
|
|
|
If you are a developer, we can set up a local development environment with the following commands after we installed dependencies.
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
git clone git@github.com:iresty/apisix.git
|
|
|
|
|
cd apisix
|
2019-09-12 10:56:47 +08:00
|
|
|
|
|
|
|
|
|
# init submodule
|
|
|
|
|
git submodule update --init --recursive
|
|
|
|
|
|
|
|
|
|
# install dependency
|
2019-07-18 16:09:30 +08:00
|
|
|
|
make dev
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
If all goes well, you will see this message at the end:
|
|
|
|
|
|
|
|
|
|
> Stopping after installing dependencies for apisix
|
|
|
|
|
|
|
|
|
|
The following is the expected development environment directory structure:
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
$ tree -L 2 -d apisix
|
|
|
|
|
apisix
|
2019-09-12 10:56:47 +08:00
|
|
|
|
├── benchmark
|
|
|
|
|
│ ├── fake-apisix
|
|
|
|
|
│ └── server
|
2019-07-18 16:09:30 +08:00
|
|
|
|
├── bin
|
|
|
|
|
├── conf
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ └── cert
|
|
|
|
|
├── dashboard
|
|
|
|
|
│ ├── css
|
|
|
|
|
│ ├── fonts
|
|
|
|
|
│ ├── img
|
|
|
|
|
│ ├── js
|
|
|
|
|
│ └── tinymce
|
|
|
|
|
├── deps # dependent Lua and dynamic libraries
|
2019-07-18 16:09:30 +08:00
|
|
|
|
│ ├── lib64
|
|
|
|
|
│ └── share
|
|
|
|
|
├── doc
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ ├── images
|
|
|
|
|
│ └── plugins
|
|
|
|
|
├── logs
|
2019-07-18 16:09:30 +08:00
|
|
|
|
├── lua
|
|
|
|
|
│ └── apisix
|
2019-09-12 10:56:47 +08:00
|
|
|
|
├── rockspec
|
2019-07-18 16:09:30 +08:00
|
|
|
|
├── t
|
|
|
|
|
│ ├── admin
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ ├── config-center-yaml
|
2019-07-18 16:09:30 +08:00
|
|
|
|
│ ├── core
|
|
|
|
|
│ ├── lib
|
|
|
|
|
│ ├── node
|
2019-09-12 10:56:47 +08:00
|
|
|
|
│ ├── plugin
|
|
|
|
|
│ ├── router
|
|
|
|
|
│ └── servroot
|
2019-07-18 16:09:30 +08:00
|
|
|
|
└── utils
|
|
|
|
|
```
|
|
|
|
|
|
2019-09-16 21:40:39 +08:00
|
|
|
|
## Manage (start/stop) APISIX Server
|
|
|
|
|
|
|
|
|
|
We can start the APISIX server by command `make run` in apisix home folder,
|
|
|
|
|
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
|
|
|
|
|
./bin/apisix init
|
|
|
|
|
./bin/apisix init_etcd
|
|
|
|
|
|
|
|
|
|
# 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:
|
|
|
|
|
|
|
|
|
|
help: Show Makefile rules.
|
|
|
|
|
dev: Create a development ENV
|
2019-09-12 10:56:47 +08:00
|
|
|
|
check: Check Lua source code
|
2019-07-18 16:09:30 +08:00
|
|
|
|
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
|
2019-09-12 10:56:47 +08:00
|
|
|
|
test: Run the test case
|
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)`
|
|
|
|
|
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: `prove -Itest-nginx/lib -r t`
|
2019-07-18 16:09:30 +08:00
|
|
|
|
|