Linux系统安装OpenResty

一、OpenResty® 为如下Linux系统发布版本提供官方预发布包

o Ubuntu

  • 14.04 Trusty amd64
  • 16.04 Xenial amd64, arm64
  • 18.04 Bionic amd64, arm64
  • 20.04 Focal amd64, arm64

o Debian

  • 8.x Jessie amd64
  • 9.x Stretch amd64, arm64
  • 10.x Buster amd64, arm64

o CentOS

  • 6.x x86_64
  • 7.x x86_64, aarch64
  • 8.x x86_64, aarch64

o Red Hat Enterprise Linux (RHEL)

  • 6.x x86_64
  • 7.x x86_64, aarch64
  • 8.x x86_64, aarch64

o Fedora

  • 31 x86_64
  • 32 x86_64, aarch64
  • 33 x86_64, aarch64
  • 34 x86_64, aarch64

o Amazon Linux

  • 1 (2018.03) x86_64
  • 2 x86_64, aarch64

o SUSE Linux Enterprise

  • 12.x x86_64
  • 15.x x86_64, aarch64

o OpenSUSE Leap

  • 15.x x86_64, aarch64

o Alpine

  • 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

所有发布版本的包均使用GPG key, 0xD5EDEB74:https://openresty.org/package/pubkey.gpg 作为签名

重要提示:所有官方对于Intel x86_64的二进制包,需要CPU支持SSE 4.2。如果老版本不支持SSE 4.2,需要使用OpenResty源码包构建针对指定CPU的。否则,你在缺少SSE 4.2支持的CPU上使用二进制包时会看到Illegal instruction错误。

二、Linux发行版下安装步骤

Ubuntu

注意: 如果nginx已经安装并且运行,需要在安装openresty前关闭它。否则,安装可能会失败。
sudo systemctl disable nginx
sudo systemctl stop nginx

安装实操步骤:

# 步骤1:安装GPG 公共keys的依赖
​
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
​
# 步骤2:导入GPG key
​
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
​
# 步骤3:加入官方的APT 库.
​
## 对于x86_64 或者amd64 系统
echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list ​ ## 对于 arm64 或者aarch64 系统 ​ echo "deb http://openresty.org/package/arm64/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list ​ # 步骤4:更新APT 索引 ​ sudo apt-get update ​ # 步骤5:安装openresty包 ​ sudo apt-get -y install openresty ​ 上述安装会默认将 openresty-opm 和openresty-restydoc 包安装。如果不需要这个包,可以使用如下命令 ​ sudo apt-get -y install --no-install-recommends openresty

 

Debian

注意: 如果nginx已经安装并且运行,需要在安装openresty前关闭它。否则,安装可能会失败。
sudo systemctl disable nginx
sudo systemctl stop nginx

安装实操步骤:

# 步骤1:安装GPG 公共keys的依赖
​
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
​
# 步骤2:导入GPG key
​
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
​
# 步骤3:加入官方的APT 库.
​
## 对于x86_64 或者amd64 系统
​
codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release`
​
echo "deb http://openresty.org/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 http://openresty.org/package/arm64/debian $codename openresty" | sudo tee /etc/apt/sources.list.d/openresty.list
​
# 步骤4:更新APT 索引
​
sudo apt-get update
​
# 步骤5:安装openresty包
​
sudo apt-get -y install openresty
​
上述安装会默认将 openresty-opm 和openresty-restydoc 包安装。如果不需要这个包,可以使用如下命令
​
sudo apt-get -y install --no-install-recommends openresty
 

CentOS

在CentOS中使用yum添加安装包的库源,在CentOS 8+ 将yum替换成dnf。
安装实操步骤:
*# add the yum repo:*wget https://openresty.org/package/centos/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/*# update the yum index:*sudo yum check-update
​
安装openresty包
​
sudo yum install openresty
​
如果需要安装 resty 命令行,则使用如下命令:
​
sudo yum install openresty-resty
​
列出 openresty 源下可用的安装包:
​
sudo yum --disablerepo="*" --enablerepo="openresty" list available
 

RHEL

在CentOS中使用yum添加安装包的库源,在RHEL 8+ 将yum替换成dnf

*# add the yum repo:*wget https://openresty.org/package/rhel/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/*# update the yum index:*sudo yum check-update
​
安装openresty包
​
sudo yum install openresty
​
如果需要安装 resty 命令行,则使用如下命令:
​
sudo yum install openresty-resty
​
列出 openresty 源下可用的安装包:
​
sudo yum --disablerepo="*" --enablerepo="openresty" list available
这个库中有些包,像 perl-Test-Nginx 和perl-Lemplate 需要扩展的RHEL 官方源enabled。

在RHEL7上,使用如下命令:

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

注意:perl-Lemplate RPM 包目前在RHEL 8 上不可用,由于它的官网一处了一些Perl 模块包的依赖,例如:perl-Template-Toolkit

Fedora

安装实操步骤:
在Fedora system上启用openresty repository:
​
*# add the repo:*wget https://openresty.org/package/fedora/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/*# update the index:*sudo dnf check-update
​
安装openresty包
​
sudo dnf install -y openresty
​
如果需要安装 resty 命令行,则使用如下命令:
​
sudo dnf install -y openresty-resty
​
列出 openresty 源下可用的安装包:
​
sudo dnf repo-pkgs openresty list available

Amazon Linux

安装实操步骤:

在Amazon Linux 系统上启用openresty repository:
​
*# add the repo:*wget https://openresty.org/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 命令行,则使用如下命令:
​
sudo yum install -y openresty-resty
​
列出 openresty 源下可用的安装包:
​
sudo yum --disablerepo="*" --enablerepo="openresty" list available
注意: *-asan RPM 包目前在Amazon Linux 2上不可用,由于Amazon Linux's 官方BUG,clang 包的原因 (缺少libclang_rt.a 库文件)。

SUSE Linux Enterprise

安装实操步骤:

在 SUSE Linux Enterprise Server/Desktop/Workstation (SLES) 系统上启用openresty repository:
​
sudo rpm --import https://openresty.org/package/pubkey.gpg
sudo zypper ar -g --refresh --check "https://openresty.org/package/sles/openresty.repo"sudo zypper mr --gpgcheck-allow-unsigned-repo openresty
​
安装openresty包
​
sudo zypper install openresty
​
如果需要安装 resty 命令行,则使用如下命令:
​
sudo zypper install -y openresty-resty
​
列出 openresty 源下可用的安装包:
​
sudo zypper pa -r openresty

 

OpenSUSE Leap

安装实操步骤:
在OpenSUSE Leap 系统上启用openresty repository:
​
sudo rpm --import https://openresty.org/package/pubkey.gpg
sudo zypper ar -g --refresh --check https://openresty.org/package/opensuse/openresty.repo
sudo zypper mr --gpgcheck-allow-unsigned-repo openresty
​
导入PGP key:
​
sudo zypper --gpg-auto-import-keys refresh
​
安装openresty包
​
sudo zypper install openresty
​
如果需要安装 resty 命令行,则使用如下命令:
​
sudo zypper install -y openresty-resty
​
列出 openresty 源下可用的安装包:
​
sudo zypper pa -r openresty

 

Alpine

安装实操步骤:

首先,需要你保证启用Alpine's 官方社区repository. 编辑 /etc/apk/repositories 文件,取消如下注释:
​
http://mirror.leaseweb.com/alpine/v3.11/community
​
在Alpine 系统上启用openresty 源,如下所示:
​
*# first, let's add the public key used to sign the repo:*
wget 'http://openresty.org/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 "http://openresty.org/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 命令行,则使用如下命令:
​
sudo apk add openresty-resty
​
列出 openresty 源下可用的安装包:
​
apk list | grep 'openresty\|lemplate'

 

 

posted @ 2021-09-06 11:12  MENGXP  阅读(375)  评论(0编辑  收藏  举报