如何在 K8s 环境中自动管理网关服务器(使用 OpenResty Edge)
OpenResty® Linux 软件包
Yichun Zhang (agentzh) , 2024 年 1 月 8 日 (创建于 2016 年 7 月 14 日)OpenResty® 为以下 Linux 发行版和版本提供官方预构建软件包。
Version Codename Supported Architectures
14.04 Trusty amd64
16.04 Xenial amd64, arm64
18.04 Bionic amd64, arm64
20.04 Focal amd64, arm64
22.04 Jammy amd64, arm64
Version Codename Supported Architectures
9.x Stretch amd64, arm64
10.x Buster amd64, arm64
11.x Bullseye amd64, arm64
12.x Bookworm amd64, arm64
Version Supported Architectures
6.x x86_64
7.x x86_64, aarch64
8.x x86_64, aarch64
9.x x86_64, aarch64
Version Supported Architectures
6.x x86_64
7.x x86_64, aarch64
8.x x86_64, aarch64
9.x x86_64, aarch64
Version Supported Architectures
32 x86_64, aarch64
33 x86_64, aarch64
34 x86_64, aarch64
35 x86_64, aarch64
36 x86_64, aarch64
Version Supported Architectures
1 (2018.03) x86_64
2 x86_64, aarch64
2023 x86_64, aarch64
Version Supported Architectures
2 x86_64, aarch64
3 x86_64, aarch64
Version Supported Architectures
2 x86_64, aarch64
3 x86_64, aarch64
Version Supported Architectures
8.x x86_64, aarch64
9.x x86_64, aarch64
Version Supported Architectures
6.x x86_64
7.x x86_64, aarch64
8.x x86_64, aarch64
Version Supported Architectures
12.x x86_64
15.x x86_64, aarch64
Version Supported Architectures
15.x x86_64, aarch64
Version Supported Architectures
3.7 x86_64, aarch64
3.8 x86_64, aarch64
3.9 x86_64, aarch64
3.10 x86_64, aarch64
3.11 x86_64, aarch64
3.12 x86_64, aarch64
3.13 x86_64, aarch64
3.14 x86_64, aarch64
3.15 x86_64, aarch64
3.16 x86_64, aarch64
3.17 x86_64, aarch64
3.18 x86_64, aarch64
Version Supported Architectures
2.0 x86_64, aarch64
我们所有存储库的元数据(以及 rpm 二进制软件包)都使用以下 GPG 密钥 0xD5EDEB74
签署
https://openresty.org.cn/package/pubkey.gpg
重要! 适用于 Intel x86_64
CPU 的所有官方二进制软件包都需要 CPU 中的 SSE 4.2 指令支持。如果您使用的是不支持 SSE 4.2 的旧 CPU,则需要在该 CPU 上从源代码包自行构建 OpenResty。有关详细信息,请参阅 下载 和 安装 页面。否则,在缺少 SSE 4.2 支持的 CPU 上使用二进制软件包时,您将看到 Illegal instruction
错误。
Ubuntu
注意:如果 nginx 已经安装并运行,请尝试在安装 openresty 之前禁用并停止它,如下所示
sudo systemctl disable nginx
sudo systemctl stop nginx
否则安装可能会失败。
您可以将我们的 APT 存储库添加到您的 Ubuntu 系统,以便在将来轻松安装我们的软件包并接收更新(通过 apt-get update
命令)。要添加存储库,只需运行以下命令(每个系统只需运行一次)
步骤 1:我们应该通过添加 GPG 公钥来安装一些添加 GPG 公钥所需的前提条件(稍后可以删除)
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates lsb-release
步骤 2:导入我们的 GPG 密钥
对于 ubuntu 16 ~ 20
wget -O - https://openresty.org.cn/package/pubkey.gpg | sudo apt-key add -
对于 ubuntu 22
wget -O - https://openresty.org.cn/package/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/openresty.gpg
步骤 3:然后添加我们官方的 APT 存储库。
对于 x86_64
或 amd64
系统
对于 ubuntu 16 ~ 20
echo "deb https://openresty.org.cn/package/ubuntu $(lsb_release -sc) main" \ | sudo tee /etc/apt/sources.list.d/openresty.list
对于 ubuntu 22 或更高版本
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] https://openresty.org.cn/package/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list > /dev/null
以及对于 arm64
或 aarch64
系统
对于 ubuntu 16 ~ 20
echo "deb https://openresty.org.cn/package/arm64/ubuntu $(lsb_release -sc) main" \ | sudo tee /etc/apt/sources.list.d/openresty.list
对于 ubuntu 22 或更高版本
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] https://openresty.org.cn/package/arm64/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list > /dev/null
步骤 4:更新 APT 索引
sudo apt-get update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo apt-get -y install openresty
此软件包还推荐 openresty-opm
和 openresty-restydoc
软件包,因此默认情况下,后两个软件包也会自动安装。如果您不希望这样做,可以禁用推荐软件包的自动安装,如下所示
sudo apt-get -y install --no-install-recommends openresty
有关此存储库中所有可用软件包的更多详细信息,请参阅 OpenResty Deb 软件包 页面。
Debian
注意:如果 nginx 已经安装并运行,请尝试在安装 openresty 之前禁用并停止它,如下所示
sudo systemctl disable nginx
sudo systemctl stop nginx
否则安装可能会失败。
您可以将 openresty
存储库添加到您的 Debian 系统,以便在将来轻松安装我们的软件包并接收更新(通过 apt-get update
命令)。
要添加存储库,只需运行以下命令(每个系统只需运行一次)
步骤 1:安装通过添加 GPG 公钥来安装一些添加 GPG 公钥所需的前提条件(稍后可以删除)
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
步骤 2:导入我们的 GPG 密钥
对于 debian <= 11
wget -O - https://openresty.org.cn/package/pubkey.gpg | sudo apt-key add -
对于 debian >= 12
wget -O - https://openresty.org.cn/package/pubkey.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/openresty.gpg
步骤 3:添加我们官方的 APT 存储库。
对于 x86_64
或 amd64
系统
codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release`
echo "deb https://openresty.org.cn/package/debian $codename openresty" \
| sudo tee /etc/apt/sources.list.d/openresty.list
以及对于 arm64
或 aarch64
系统
codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release`
echo "deb https://openresty.org.cn/package/arm64/debian $codename openresty" \
| sudo tee /etc/apt/sources.list.d/openresty.list
步骤 4:更新 APT 索引
sudo apt-get update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo apt-get -y install openresty
此软件包还推荐 openresty-opm
和 openresty-restydoc
软件包,因此默认情况下,后两个软件包也会自动安装。如果您不希望这样做,可以禁用推荐软件包的自动安装,如下所示
sudo apt-get -y install --no-install-recommends openresty
有关此存储库中所有可用软件包的更多详细信息,请参阅 OpenResty Deb 软件包 页面。
CentOS
您可以将 openresty
存储库添加到您的 CentOS 系统,以便在将来轻松安装我们的软件包并接收更新(通过 yum update
命令)。要添加存储库,只需运行以下命令(如果您使用的是 CentOS 8+,请在下面将 yum
替换为 dnf
)
CentOS 9 或更高版本
# add the yum repo:
wget https://openresty.org.cn/package/centos/openresty2.repo
sudo mv openresty2.repo /etc/yum.repos.d/openresty.repo
# update the yum index:
sudo yum check-update
CentOS 8 或更早版本
# add the yum repo:
wget https://openresty.org.cn/package/centos/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/openresty.repo
# update the yum index:
sudo yum check-update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo yum install openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list available
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
对于 CentOS 8 及更高版本,我们只需要将上面的 yum
命令替换为 dnf
。
RHEL
您可以将 openresty
存储库添加到您的 Red Hat Enterprise Linux (RHEL) 系统,以便在将来轻松安装我们的软件包并接收更新(通过 yum update
命令)。要添加存储库,只需运行以下命令(如果您使用的是 RHEL 8+,请在下面将 yum
替换为 dnf
)
RHEL 9 或更高版本
# add the yum repo:
wget https://openresty.org.cn/package/rhel/openresty2.repo
sudo mv openresty2.repo /etc/yum.repos.d/openresty.repo
# update the yum index:
sudo yum check-update
RHEL 8 或更早版本
# add the yum repo:
wget https://openresty.org.cn/package/rhel/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/openresty.repo
# update the yum index:
sudo yum check-update
添加软件包存储库后,您现在可以安装一个软件包,例如,openresty
,如下所示
sudo yum install openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list available
此存储库中的某些软件包,如 perl-Test-Nginx
和 perl-Lemplate
,确实需要启用一些额外的可选 RHEL 官方存储库。在 RHEL 7 和 6 上,您需要启用“可选”rpm 存储库,例如,对于 RHEL 7
sudo subscription-manager repos --enable rhel-7-server-optional-rpms
以及对于 RHEL 6
sudo subscription-manager repos --enable rhel-6-server-optional-rpms
以及对于 RHEL 8,您需要启用“CodeReady”Linux Builder 存储库,如下所示
sudo subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
请注意,perl-Lemplate
RPM 软件包目前在 RHEL 8 上不可用,因为其官方存储库删除了一些依赖 Perl 模块软件包,如 perl-Template-Toolkit
(与 RHEL 7 相比)。
对于 RHEL 8 及更高版本,我们只需要将上面的 yum
命令替换为 dnf
。
Fedora
您可以在 Fedora 系统上启用 openresty
存储库,如下所示
# add the repo:
wget https://openresty.org.cn/package/fedora/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
# update the index:
sudo dnf check-update
然后,您可以轻松地从openresty-openresty
仓库安装软件包,并在将来接收更新(通过dnf check-update
命令)。例如,要安装openresty
软件包,我们可以运行以下命令
sudo dnf install -y openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo dnf install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
要列出openresty-openresty
仓库中所有可用的软件包,只需键入
sudo dnf repo-pkgs openresty list available
有关这些软件包的更多详细信息,请参见OpenResty RPM Packages页面。
Amazon Linux
您可以在您的 Amazon Linux 系统上像这样启用openresty
仓库
# add the repo:
wget https://openresty.org.cn/package/amazon/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
# update the index:
sudo yum check-update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo yum install -y openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list available
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
请注意,由于 Amazon Linux 官方 clang 软件包中的错误(缺少libclang_rt.a
库文件),*-asan
RPM 软件包目前在 Amazon Linux 2 上不可用。
阿里云 Linux
您可以在您的阿里云 Linux 系统上像这样启用openresty
仓库
# add the repo:
wget https://openresty.org.cn/package/alinux/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
# update the index:
sudo yum check-update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo yum install -y openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
腾讯云 Linux
您可以在您的腾讯云 Linux 系统上像这样启用openresty
仓库
# add the repo:
wget https://openresty.org.cn/package/tlinux/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
# update the index:
sudo yum check-update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo yum install -y openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
Rocky Linux
您可以在您的 Rocky Linux 系统上像这样启用openresty
仓库
Rocky 9 或更高版本
# add the repo:
wget https://openresty.org.cn/package/rocky/openresty2.repo
sudo mv openresty2.repo /etc/yum.repos.d/openresty.repo
# update the index:
sudo yum check-update
Rocky 8
# add the repo:
repo=openresty.repo
wget https://openresty.org.cn/package/rocky/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/openresty.repo
# update the index:
sudo yum check-update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo yum install -y openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
Oracle Linux
您可以在您的 Oracle Linux 系统上像这样启用openresty
仓库
# add the repo:
wget https://openresty.org.cn/package/oracle/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
# update the index:
sudo yum check-update
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo yum install -y openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
SUSE Linux Enterprise
您可以在您的 SUSE Linux Enterprise Server/Desktop/Workstation (SLES) 系统上像下面这样启用openresty
仓库
sudo rpm --import https://openresty.org.cn/package/pubkey.gpg
sudo zypper ar -g --refresh --check "https://openresty.org.cn/package/sles/openresty.repo"
sudo zypper mr --gpgcheck-allow-unsigned-repo openresty
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo zypper install openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo zypper install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo zypper pa -r openresty
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
OpenSUSE Leap
您可以在您的 OpenSUSE Leap 系统上像下面这样启用openresty
仓库
sudo rpm --import https://openresty.org.cn/package/pubkey.gpg
sudo zypper ar -g --refresh --check https://openresty.org.cn/package/opensuse/openresty.repo
sudo zypper mr --gpgcheck-allow-unsigned-repo openresty
然后导入我们的 PGP 密钥
sudo zypper --gpg-auto-import-keys refresh
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo zypper install openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo zypper install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo zypper pa -r openresty
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
Alpine
首先,请确保您已启用 Alpine 的官方社区仓库。基本上,您可以打开文件/etc/apk/repositories
并取消注释看起来像这样的行
http://mirror.leaseweb.com/alpine/v3.11/community
当您使用不同的镜像站点或不同的 Alpine 版本时,您的实际行可能略有不同。
您可以在您的 Alpine 系统上像下面这样启用openresty
仓库
# first, let's add the public key used to sign the repo:
wget 'https://openresty.org.cn/package/admin@openresty.com-5ea678a6.rsa.pub'
sudo mv 'admin@openresty.com-5ea678a6.rsa.pub' /etc/apk/keys/
# then, add the repo:
. /etc/os-release
MAJOR_VER=`echo $VERSION_ID | sed 's/\.[0-9]\+$//'`
echo "https://openresty.org.cn/package/alpine/v$MAJOR_VER/main" \
| sudo tee -a /etc/apk/repositories
# update the local index cache:
sudo apk update
然后,我们可以像这样安装openresty
软件包
sudo apk add openresty
如果您想安装resty
命令行工具,只需安装下面openresty-resty
软件包
sudo apk add openresty-resty
opm
命令行工具位于openresty-opm
软件包中,而restydoc
工具位于openresty-restydoc
软件包中。
要查看我们仓库提供的所有软件包,键入以下命令
apk list | grep 'openresty\|lemplate'
有关所有这些软件包的更多详细信息,请参见OpenResty Alpine APK Packages页面。
CBL-Mariner
您可以在您的 CBL-Mariner 系统上像这样启用openresty
仓库
# add the repo:
wget https://openresty.org.cn/package/mariner/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
# update the index:
sudo yum makecache
然后您可以安装一个软件包,例如,openresty
,如下所示
sudo yum install -y openresty
如果您想安装 resty
命令行实用程序,请安装 openresty-resty
软件包,如下所示
sudo yum install -y openresty-resty
opm
命令行实用程序位于 openresty-opm
软件包中,而 restydoc
实用程序位于 openresty-doc
软件包中。
列出 openresty
存储库中的所有软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list
有关所有这些软件包的更多详细信息,请参阅 OpenResty RPM 软件包 页面。
更多 Linux 发行版的支持
我们欢迎社区贡献针对更多 Linux 发行版(如 Gentoo、Arch 和 Slackware)的打包来源。请确保生成的软件包尽可能类似于我们现有的RPM Packages。谢谢!
非 Linux 系统的软件包
我们还提供适用于 Windows 操作系统的预构建二进制软件包。您可以在Download页面获取它。