You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/06/27 02:42:32 UTC

[GitHub] [apisix] SylviaBABY commented on a diff in pull request #7318: docs: add building apisix Chinese doc.

SylviaBABY commented on code in PR #7318:
URL: https://github.com/apache/apisix/pull/7318#discussion_r906928092


##########
docs/zh/latest/building-apisix.md:
##########
@@ -0,0 +1,280 @@
+---
+id: building-apisix
+title: 源码安装 APISIX
+keywords:
+  - API 网关
+  - Apache APISIX
+  - 贡献代码
+  - 构建 APISIX
+  - 源码安装 APISIX
+description: 本文介绍了如何在本地使用源码安装 API 网关 Apache APISIX 来构建开发环境。
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+如果你希望为 APISIX 做出贡献或配置开发环境,你可以参考本教程。
+
+如果你想通过其他方式安装 APISIX,你可以参考[安装指南](./installation-guide.md)。
+
+:::note
+
+如果你想为特定的环境或打包 APISIX,请参考 [apisix-build-tools](https://github.com/api7/apisix-build-tools)。
+
+:::
+
+## 源码安装 APISIX
+
+首先,你可以通过以下命令安装依赖项:
+
+```shell
+curl https://raw.githubusercontent.com/apache/apisix/master/utils/install-dependencies.sh -sL | bash -
+```
+
+然后,创建一个目录并设置环境变量 `APISIX_VERSION`:
+
+```shell
+APISIX_VERSION='2.14.1'
+mkdir apisix-${APISIX_VERSION}
+```
+
+现在,你可以运行以下命令来下载 APISIX 源码包:
+
+```shell
+wget https://downloads.apache.org/apisix/${APISIX_VERSION}/apache-apisix-${APISIX_VERSION}-src.tgz
+```
+
+你可以从[下载页面](https://apisix.apache.org/downloads/)下载源码包。你也可以在该页面找到 APISIX Dashboard 和 APISIX Ingress Controller 的源码包。
+
+下载源码包后,你可以将文件解压到之前创建的文件夹中:
+
+```shell
+tar zxvf apache-apisix-${APISIX_VERSION}-src.tgz -C apisix-${APISIX_VERSION}
+```
+
+然后切换到解压的目录,创建依赖项并安装 APISIX,如下所示:
+
+```shell
+cd apisix-${APISIX_VERSION}
+make deps
+make install
+```
+
+该命令将安装 APISIX 运行时依赖的 Lua 库和 `apisix` 命令。
+
+:::note
+
+如果你在运行 `make deps` 时收到类似 `Could not find header file for LDAP/PCRE/openssl` 的错误消息,请使用此解决方案。
+
+`luarocks` 支持自定义编译时依赖项(请参考:[配置文件格式](https://github.com/luarocks/luarocks/wiki/Config-file-format))。你可以使用第三方工具安装缺少的软件包并将其安装目录添加到 `luarocks` 变量表中。此方法适用于 macOS、Ubuntu、CentOS 和其他类似操作系统。
+
+此处仅给出 macOS 的具体解决步骤,其他操作系统的解决方案类似:
+
+1. 安装 `openldap`:
+
+   ```shell
+   brew install openldap
+   ```
+
+2. 使用以下命令命令找到本地安装目录:
+
+   ```shell
+   brew --prefix openldap
+   ```
+
+3. 将路径添加到项目配置文件中(选择两种方法中的一种即可):
+   1. 你可以使用 `luarocks config` 命令设置 `LDAP_DIR`:
+
+      ```shell
+      luarocks config variables.LDAP_DIR /opt/homebrew/cellar/openldap/2.6.1
+      ```
+
+   2. 你还可以更改 `luarocks` 的默认配置文件。打开 `~/.luaorcks/config-5.1.lua` 文件并添加以下内容:
+
+      ```shell
+      variables = { LDAP_DIR = "/opt/homebrew/cellar/openldap/2.6.1", LDAP_INCDIR = "/opt/homebrew/cellar/openldap/2.6.1/include", }
+      ```
+
+      `/opt/homebrew/cellar/openldap/` 是 `brew` 在 macOS(Apple Silicon) 上安装 `openldap` 的默认位置。`/usr/local/opt/openldap/` 是 brew 在 macOS(Intel) 上安装 openldap 的默认位置。
+
+:::
+
+如果你不再需要 APISIX,可以执行以下命令卸载:
+
+```shell
+make uninstall && make undeps
+```
+
+:::danger
+
+该操作将删除所有相关文件。
+
+:::
+
+## 安装 etcd
+
+APISIX 默认使用 [etcd](https://github.com/etcd-io/etcd) 来保存和同步配置。在运行 APISIX 之前,你需要在你的机器上安装 etcd。
+
+<Tabs
+  groupId="os"
+  defaultValue="linux"
+  values={[
+    {label: 'Linux', value: 'linux'},
+    {label: 'macOS', value: 'mac'},
+  ]}>
+<TabItem value="linux">
+
+```shell
+ETCD_VERSION='3.4.18'
+wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz
+tar -xvf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz && \
+  cd etcd-v${ETCD_VERSION}-linux-amd64 && \
+  sudo cp -a etcd etcdctl /usr/bin/
+nohup etcd >/tmp/etcd.log 2>&1 &
+```
+
+</TabItem>
+
+<TabItem value="mac">
+
+```shell
+brew install etcd
+brew services start etcd
+```
+
+</TabItem>
+</Tabs>
+
+## 管理 APISIX 服务
+
+运行以下命令初始化 NGINX 配置文件和 etcd。
+
+```shell
+apisix init
+```
+
+:::tip
+
+你可以运行 `apisix help` 命令,查看返回结果,获取其他操作命令及其描述。
+
+:::
+
+运行以下命令测试配置文件,APISIX 将根据 `config.yaml` 生成 `nginx.conf`,并检查 `nginx.conf` 的语法是否正确。
+
+```shell
+apisix test
+```
+
+最后,你可以使用以下命令运行 APISIX。
+
+```shell
+apisix start
+```
+
+如果需要停止 APISIX,你可以使用 `apisix quit` 或者 `apisix stop` 命令。
+
+`apisix quit` 将正常关闭 APISIX,该指令确保在停止之前完成所有收到的请求。
+
+```shell
+apisix quit
+```
+
+`apisix stop` 命令会强制关闭 APISIX 并丢弃所有请求。
+
+```shell
+apisix stop
+```
+
+## 为 APISIX 构建 apisix-base

Review Comment:
   ```suggestion
   ## 为 APISIX 构建 APISIX-Base
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org