|
1 | 1 | --- |
2 | | -title: Get APISIX |
3 | | -description: This tutorial uses a script to quickly install Apache APISIX in your local environment and verify it through the Admin API. |
| 2 | +title: Getting Started with Apache APISIX |
| 3 | +description: Install and run Apache APISIX in minutes. This guide covers Docker-based setup, verification, basic route configuration, and next steps for production deployment. |
4 | 4 | --- |
5 | 5 |
|
6 | | -<head> |
7 | | - <link rel="canonical" href="https://docs.api7.ai/apisix/getting-started/" /> |
8 | | -</head> |
| 6 | +Apache APISIX is an open-source, high-performance API gateway and AI gateway built for cloud-native architectures. It provides dynamic routing, load balancing, authentication, rate limiting, observability, and 100+ plugins for managing API traffic at scale. |
9 | 7 |
|
10 | | -> The Getting Started tutorials are contributed by [API7.ai](https://api7.ai/). |
| 8 | +This guide walks you through installing APISIX locally, verifying the installation, and configuring your first API route. |
11 | 9 |
|
12 | | -Developed and donated by API7.ai, Apache APISIX is an open source, dynamic, scalable, and high-performance cloud native API gateway for all your APIs and microservices. It is a [top-level project](https://projects.apache.org/project.html?apisix) of the Apache Software Foundation. |
| 10 | +## Prerequisites |
13 | 11 |
|
14 | | -You can use APISIX API Gateway as a traffic entrance to process all business data. It offers features including dynamic routing, dynamic upstream, dynamic certificates, A/B testing, canary release, blue-green deployment, limit rate, defense against malicious attacks, metrics, monitoring alarms, service observability, service governance, and more. |
| 12 | +Before you begin, ensure you have the following installed: |
15 | 13 |
|
16 | | -This tutorial uses a script to quickly install [Apache APISIX](https://api7.ai/apisix) in your local environment and verifies the installation through the Admin API. |
| 14 | +- [Docker](https://docs.docker.com/get-docker/) (version 20.10 or later) — used to run APISIX and etcd containers |
| 15 | +- [curl](https://curl.se/) — used to send requests to APISIX for validation |
17 | 16 |
|
18 | | -## Prerequisite(s) |
| 17 | +APISIX uses [etcd](https://etcd.io/) as its configuration store. The quickstart script handles etcd setup automatically. |
19 | 18 |
|
20 | | -The quickstart script relies on several components: |
| 19 | +## Install APISIX |
21 | 20 |
|
22 | | -* [Docker](https://docs.docker.com/get-docker/) is used to install the containerized **etcd** and **APISIX**. |
23 | | -* [curl](https://curl.se/) is used to send requests to APISIX for validation. |
24 | | - |
25 | | -## Get APISIX |
26 | | - |
27 | | -:::caution |
28 | | - |
29 | | -To provide a better experience in this tutorial, the authorization of Admin API is switched off by default. Please turn on the authorization of Admin API in the production environment. |
30 | | - |
31 | | -::: |
32 | | -APISIX can be easily installed and started with the quickstart script: |
| 21 | +APISIX can be installed with a single command using the quickstart script: |
33 | 22 |
|
34 | 23 | ```shell |
35 | 24 | curl -sL https://run.api7.ai/apisix/quickstart | sh |
36 | 25 | ``` |
37 | 26 |
|
38 | | -The script should start two Docker containers, _apisix-quickstart_ and _etcd_. APISIX uses etcd to save and synchronize configurations. Both the etcd and the APISIX use [**host**](https://docs.docker.com/network/host/) Docker network mode. That is, the APISIX can be accessed from local. |
| 27 | +This script starts two Docker containers: |
| 28 | + |
| 29 | +- **apisix-quickstart** — the APISIX gateway, listening on ports 9080 (HTTP) and 9443 (HTTPS) |
| 30 | +- **etcd** — the configuration store |
| 31 | + |
| 32 | +Both containers use Docker [host network mode](https://docs.docker.com/network/host/), so APISIX is accessible directly from localhost. |
39 | 33 |
|
40 | 34 | You will see the following message once APISIX is ready: |
41 | 35 |
|
42 | 36 | ```text |
43 | 37 | ✔ APISIX is ready! |
44 | 38 | ``` |
45 | 39 |
|
46 | | -## Validate |
| 40 | +:::caution |
47 | 41 |
|
48 | | -Once APISIX is running, you can use curl to interact with it. Send a simple HTTP request to validate if APISIX is working properly: |
| 42 | +The quickstart script disables Admin API authorization by default for ease of use. Always enable Admin API authentication in production environments. See the [Admin API documentation](../admin-api.md) for details. |
| 43 | + |
| 44 | +::: |
| 45 | + |
| 46 | +### Alternative Installation Methods |
| 47 | + |
| 48 | +| Method | Use Case | Documentation | |
| 49 | +|--------|----------|---------------| |
| 50 | +| Docker Compose | Production-like local setup with custom configuration | [apisix-docker](https://github.com/apache/apisix-docker) | |
| 51 | +| Helm Chart | Kubernetes deployment | [apisix-helm-chart](https://github.com/apache/apisix-helm-chart) | |
| 52 | +| RPM Package | CentOS/RHEL bare-metal installation | [Installation Guide](../installation-guide.md) | |
| 53 | +| Source Build | Development and custom builds | [How to Build](../building-apisix.md) | |
| 54 | + |
| 55 | +## Verify the Installation |
| 56 | + |
| 57 | +Send a request to confirm APISIX is running: |
49 | 58 |
|
50 | 59 | ```shell |
51 | 60 | curl "http://127.0.0.1:9080" --head | grep Server |
52 | 61 | ``` |
53 | 62 |
|
54 | | -If everything is ok, you will get the following response: |
| 63 | +Expected response: |
55 | 64 |
|
56 | 65 | ```text |
57 | | -Server: APISIX/Version |
| 66 | +Server: APISIX/3.16.0 |
| 67 | +``` |
| 68 | + |
| 69 | +The version number reflects the APISIX release you installed. |
| 70 | + |
| 71 | +You can also check the Admin API: |
| 72 | + |
| 73 | +```shell |
| 74 | +curl "http://127.0.0.1:9180/apisix/admin/routes" | head -c 200 |
| 75 | +``` |
| 76 | + |
| 77 | +This should return a JSON response confirming the Admin API is accessible. |
| 78 | + |
| 79 | +## Configure Your First Route |
| 80 | + |
| 81 | +A **route** tells APISIX how to match client requests and forward them to upstream services. Create a route that proxies requests to the public httpbin.org service: |
| 82 | + |
| 83 | +```shell |
| 84 | +curl -i "http://127.0.0.1:9180/apisix/admin/routes/1" -X PUT -d ' |
| 85 | +{ |
| 86 | + "uri": "/get", |
| 87 | + "upstream": { |
| 88 | + "type": "roundrobin", |
| 89 | + "nodes": { |
| 90 | + "httpbin.org:80": 1 |
| 91 | + } |
| 92 | + } |
| 93 | +}' |
| 94 | +``` |
| 95 | + |
| 96 | +Now test the route: |
| 97 | + |
| 98 | +```shell |
| 99 | +curl "http://127.0.0.1:9080/get" |
| 100 | +``` |
| 101 | + |
| 102 | +You should receive a JSON response from httpbin.org, confirming that APISIX is proxying requests correctly. |
| 103 | + |
| 104 | +## Add a Plugin |
| 105 | + |
| 106 | +APISIX provides 100+ built-in [plugins](/plugins/) for authentication, traffic control, observability, and more. Add rate limiting to the route you just created: |
| 107 | + |
| 108 | +```shell |
| 109 | +curl -i "http://127.0.0.1:9180/apisix/admin/routes/1" -X PATCH -d ' |
| 110 | +{ |
| 111 | + "plugins": { |
| 112 | + "limit-count": { |
| 113 | + "count": 5, |
| 114 | + "time_window": 60, |
| 115 | + "rejected_code": 429, |
| 116 | + "key_type": "var", |
| 117 | + "key": "remote_addr" |
| 118 | + } |
| 119 | + } |
| 120 | +}' |
58 | 121 | ``` |
59 | 122 |
|
60 | | -`Version` refers to the version of APISIX that you have installed. For example, `APISIX/3.3.0`. |
| 123 | +This limits each client IP to 5 requests per minute. Send more than 5 requests within 60 seconds to see the rate limit in action: |
| 124 | + |
| 125 | +```shell |
| 126 | +for i in $(seq 1 7); do |
| 127 | + echo "Request $i:" |
| 128 | + curl -s -o /dev/null -w "HTTP %{http_code}\n" "http://127.0.0.1:9080/get" |
| 129 | +done |
| 130 | +``` |
| 131 | + |
| 132 | +Requests 1-5 should return `HTTP 200`, while requests 6-7 should return `HTTP 429`. |
| 133 | + |
| 134 | +## Access the Dashboard |
| 135 | + |
| 136 | +APISIX includes a built-in Dashboard UI for visual route and plugin management, accessible at: |
61 | 137 |
|
62 | | -You now have APISIX installed and running successfully! |
| 138 | +``` |
| 139 | +http://127.0.0.1:9180/ui |
| 140 | +``` |
| 141 | + |
| 142 | +For more details, see the [Apache APISIX Dashboard documentation](../dashboard.md). |
| 143 | + |
| 144 | +## Clean Up |
| 145 | + |
| 146 | +To stop and remove the quickstart containers: |
| 147 | + |
| 148 | +```shell |
| 149 | +docker rm -f apisix-quickstart etcd |
| 150 | +``` |
63 | 151 |
|
64 | | -APISIX includes a built-in Dashboard UI, accessible at http://127.0.0.1:9180/ui. For more guidance, please read [Apache APISIX Dashboard](../dashboard.md). |
| 152 | +## Troubleshooting |
| 153 | + |
| 154 | +**APISIX container fails to start** |
| 155 | + |
| 156 | +Check if ports 9080, 9180, or 9443 are already in use: |
| 157 | + |
| 158 | +```shell |
| 159 | +lsof -i :9080 -i :9180 -i :9443 |
| 160 | +``` |
| 161 | + |
| 162 | +**etcd connection errors** |
| 163 | + |
| 164 | +Ensure the etcd container is running: |
| 165 | + |
| 166 | +```shell |
| 167 | +docker ps | grep etcd |
| 168 | +``` |
| 169 | + |
| 170 | +If etcd is not running, restart both containers by re-running the quickstart script. |
| 171 | + |
| 172 | +**Admin API returns 401 Unauthorized** |
| 173 | + |
| 174 | +If you have enabled Admin API authentication, include the API key in your requests: |
| 175 | + |
| 176 | +```shell |
| 177 | +curl -H "X-API-KEY: your-admin-key" "http://127.0.0.1:9180/apisix/admin/routes" |
| 178 | +``` |
65 | 179 |
|
66 | 180 | ## Next Steps |
67 | 181 |
|
68 | | -The following tutorial is based on the working APISIX, please keep everything running and move on to the next step. |
| 182 | +Now that APISIX is running, explore these tutorials to learn core features: |
69 | 183 |
|
70 | | -* [Configure Routes](configure-routes.md) |
71 | | -* [Load Balancing](load-balancing.md) |
72 | | -* [Rate Limiting](rate-limiting.md) |
73 | | -* [Key Authentication](key-authentication.md) |
| 184 | +- [Configure Routes](configure-routes.md) — define routing rules and upstream services |
| 185 | +- [Load Balancing](load-balancing.md) — distribute traffic across multiple backend nodes |
| 186 | +- [Rate Limiting](rate-limiting.md) — protect services from excessive traffic |
| 187 | +- [Key Authentication](key-authentication.md) — secure APIs with API key authentication |
| 188 | +- [Plugin Hub](/plugins/) — browse all available plugins |
0 commit comments