Installation

This guide walks you through how you can install and run Apache APISIX in your environment.

Refer to the Getting Started guide for a quick walk-through on running Apache APISIX.

Installing APISIX

APISIX can be installed by the different methods listed below:

  • Docker
  • Helm
  • RPM
  • DEB
  • Source Code

First clone the apisix-docker repository:

  1. git clone https://github.com/apache/apisix-docker.git
  2. cd apisix-docker/example

Now, you can use docker-compose to start APISIX.

  • x86
  • ARM/M1
  1. docker-compose -p docker-apisix up -d
  1. docker-compose -p docker-apisix -f docker-compose-arm64.yml up -d

To install APISIX via Helm, run:

  1. helm repo add apisix https://charts.apiseven.com
  2. helm repo update
  3. helm install apisix apisix/apisix --create-namespace --namespace apisix

You can find other Helm charts on the apisix-helm-chart repository.

This installation method is suitable for CentOS 7 and Centos 8. If you choose this method to install APISIX, you need to install etcd first. For the specific installation method, please refer to Installing etcd.

Installation via RPM repository

If OpenResty is not installed, you can run the command below to install both OpenResty and APISIX repositories:

  1. sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm

If OpenResty is installed, the command below will install the APISIX repositories:

  1. sudo yum-config-manager --add-repo https://repos.apiseven.com/packages/centos/apache-apisix.repo

Then, to install APISIX, run:

  1. sudo yum install apisix
Installation - 图1tip

You can also install a specific version of APISIX by specifying it:

  1. sudo yum install apisix-3.8.0

Installation via RPM offline package

First, download APISIX RPM offline package to an apisix folder:

  1. sudo mkdir -p apisix
  2. sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm
  3. sudo yum clean all && yum makecache
  4. sudo yum install -y --downloadonly --downloaddir=./apisix apisix

Then copy the apisix folder to the target host and run:

  1. sudo yum install ./apisix/*.rpm

Managing APISIX server

Once APISIX is installed, you can initialize the configuration file and etcd by running:

  1. apisix init

To start APISIX server, run:

  1. apisix start
Installation - 图2tip

Run apisix help to get a list of all available operations.

Installation via DEB repository

Currently the only DEB repository supported by APISIX is Debian 11 (Bullseye) and supports both amd64 and arm64 architectures.

  1. # amd64
  2. wget -O - http://repos.apiseven.com/pubkey.gpg | sudo apt-key add -
  3. echo "deb http://repos.apiseven.com/packages/debian bullseye main" | sudo tee /etc/apt/sources.list.d/apisix.list
  4. # arm64
  5. wget -O - http://repos.apiseven.com/pubkey.gpg | sudo apt-key add -
  6. echo "deb http://repos.apiseven.com/packages/arm64/debian bullseye main" | sudo tee /etc/apt/sources.list.d/apisix.list

Then, to install APISIX, run:

  1. sudo apt update
  2. sudo apt install -y apisix=3.8.0-0

Managing APISIX server

Once APISIX is installed, you can initialize the configuration file and etcd by running:

  1. sudo apisix init

To start APISIX server, run:

  1. sudo apisix start
Installation - 图3tip

Run apisix help to get a list of all available operations.

If you want to build APISIX from source, please refer to Building APISIX from source.

Installing etcd

APISIX uses etcd to save and synchronize configuration. Before installing APISIX, you need to install etcd on your machine.

It would be installed automatically if you choose the Docker or Helm install method while installing APISIX. If you choose a different method or you need to install it manually, follow the steps shown below:

  • Linux
  • macOS
  1. ETCD_VERSION='3.5.4'
  2. wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz
  3. tar -xvf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz && \
  4. cd etcd-v${ETCD_VERSION}-linux-amd64 && \
  5. sudo cp -a etcd etcdctl /usr/bin/
  6. nohup etcd >/tmp/etcd.log 2>&1 &
  1. brew install etcd
  2. brew services start etcd

Next steps

Configuring APISIX

You can configure your APISIX deployment in two ways:

  1. By directly changing your configuration file (conf/config.yaml).

  2. By using the --config or the -c flag to pass the path to your configuration file while starting APISIX.

    1. apisix start -c <path to config file>

APISIX will use the configurations added in this configuration file and will fall back to the default configuration if anything is not configured. The default configurations can be found in apisix/cli/config.lua and should not be modified.

For example, to configure the default listening port to be 8000 without changing other configurations, your configuration file could look like this:

conf/config.yaml

  1. apisix:
  2. node_listen: 8000

Now, if you decide you want to change the etcd address to http://foo:2379, you can add it to your configuration file. This will not change other configurations.

conf/config.yaml

  1. apisix:
  2. node_listen: 8000
  3. deployment:
  4. role: traditional
  5. role_traditional:
  6. config_provider: etcd
  7. etcd:
  8. host:
  9. - "http://foo:2379"
Installation - 图4warning

The conf/nginx.conf file is automatically generated and should not be modified.

APISIX deployment modes

APISIX has three different deployment modes for different use cases. To learn more and configure deployment modes, see the documentation.

Updating Admin API key

It is recommended to modify the Admin API key to ensure security.

You can update your configuration file as shown below:

conf/config.yaml

  1. deployment:
  2. admin:
  3. admin_key
  4. -
  5. name: "admin"
  6. key: newsupersecurekey
  7. role: admin

Now, to access the Admin API, you can use the new key:

  1. curl http://127.0.0.1:9180/apisix/admin/routes?api_key=newsupersecurekey -i

Adding APISIX systemd unit file

If you installed APISIX via RPM, the APISIX unit file will already be configured and you can start APISIX by:

  1. systemctl start apisix
  2. systemctl stop apisix

If you installed APISIX through other methods, you can create /usr/lib/systemd/system/apisix.service and add the configuration from the template.

See the Getting Started guide for a quick walk-through of using APISIX.