1. 程式人生 > 其它 >Linux系統安裝OpenResty

Linux系統安裝OpenResty

OpenResty® 為如下Linux系統釋出版本提供官方預釋出包

o Ubuntu

Version Codename Supported Architectures

14.04 Trusty amd64

16.04 Xenial amd64, arm64

18.04 Bionic amd64, arm64

20.04 Focal amd64, arm64

o Debian

Version Codename Supported Architectures

8.x Jessie amd64

9.x Stretch amd64, arm64

10.x Buster amd64, arm64

o

CentOS

Version Supported Architectures

6.x x86_64

7.x x86_64, aarch64

8.x x86_64, aarch64

o Red Hat Enterprise Linux (RHEL)

Version Supported Architectures

6.x x86_64

7.x x86_64, aarch64

8.x x86_64, aarch64

o Fedora

Version Supported Architectures

31 x86_64

32 x86_64, aarch64

33 x86_64, aarch64

34 x86_64, aarch64

o Amazon Linux

Version Supported Architectures

1 (2018.03) x86_64

2 x86_64, aarch64

o SUSE Linux Enterprise

Version Supported Architectures

12.x x86_64

15.x x86_64, aarch64

o OpenSUSE Leap

Version Supported Architectures

15.x x86_64, aarch64

o Alpine

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

所有釋出版本的包均使用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錯誤。

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/[email protected]'

sudo mv '[email protected]' /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'