在Debian11上安裝Openresty服務(wù)(Nginx+Lua)的詳細(xì)教程
目錄
- Debian 更新系統(tǒng)
- 添加 openresty 倉庫
- 查看安裝的版本:
- 參考鏈接
OpenResty 是一個(gè)基于 Nginx 與 Lua 的高性能 Web 平臺(tái),其內(nèi)部集成了大量精良的 Lua 庫、第三方模塊以及大多數(shù)的依賴項(xiàng)。用于方便地搭建能夠處理超高并發(fā)、擴(kuò)展性極高的動(dòng)態(tài) Web 應(yīng)用、Web 服務(wù)和動(dòng)態(tài)網(wǎng)關(guān)。
OpenResty 官方 APT 包倉庫提供了 deb 包 (適用于 Ubuntu 和 Debian),可以很方便的安裝,一起來看下具體的安裝步驟吧。
Debian 更新系統(tǒng)
$ apt update # 這一步選做 $ apt upgrade
添加 openresty 倉庫
可以在 Debian 系統(tǒng)中添加 openresty 倉庫,這樣就可以方便的安裝或更新我們的軟件包(通過 apt update 命令)。
運(yùn)行下面的命令就可以添加我們的倉庫(每個(gè)系統(tǒng)只需要運(yùn)行一次):
步驟一:安裝導(dǎo)入 GPG 公鑰時(shí)所需的幾個(gè)依賴包(整個(gè)安裝過程完成后可以隨時(shí)刪除它們):
sudo apt -y install --no-install-recommends wget gnupg ca-certificates
步驟二:導(dǎo)入我們的 GPG 密鑰:
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
步驟三:添加我們官方 APT 倉庫。
對(duì)于 x86_64 或 amd64 系統(tǒng),可以使用下面的命令:
codename=`grep -Po "VERSION="[0-9]+ \(\K[^)]+" /etc/os-release` echo $codename echo "deb http://openresty.org/package/debian $codename openresty" \ | sudo tee /etc/apt/sources.list.d/openresty.list
這歷史查找當(dāng)前 debian 系統(tǒng)的版本(即 $codename 變量),更加系統(tǒng)版本再配置。
root@VM-4-14-debian:/opt# codename=`grep -Po "VERSION="[0-9]+ \(\K[^)]+" /etc/os-release` root@VM-4-14-debian:/opt# echo $codename root@VM-4-14-debian:/opt# bullseye root@VM-4-14-debian:/opt# echo "deb http://openresty.org/package/debian bullseye openresty" | sudo tee /etc/apt/sources.list.d/openresty.list deb http://openresty.org/package/debian bullseye openresty
而對(duì)于 arm64 或 aarch64 系統(tǒng),則可以使用下面的命令:
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
更新APT索引并安裝
步驟四:更新 APT 索引:
sudo apt update
然后就可以像下面這樣安裝軟件包,比如 openresty:
sudo apt -y install openresty
這個(gè)包同時(shí)也推薦安裝 openresty-opm 和 openresty-restydoc 包,所以后面兩個(gè)包會(huì)缺省安裝上。
如果你不想自動(dòng)關(guān)聯(lián)安裝,可以用下面方法關(guān)閉自動(dòng)關(guān)聯(lián)安裝:
sudo apt -y install --no-install-recommends openresty
openresty-opm 是 OpenResty 的包管理工具(OpenResty package manager)。
查看安裝的版本:
安裝目錄: /usr/local/openresty
$ nginx -v nginx version: openresty/1.21.4.1 $ /usr/local/openresty/nginx/sbin/nginx -v nginx version: openresty/1.21.4.1
使用 systemctl 可以管理openresty服務(wù):
systemctl enable openresty systemctl status openresty systemctl start openresty systemctl stop openresty systemctl restart openresty
驗(yàn)證效果,通過 curl 命令請(qǐng)求 localhost :
root@VM-4-14-debian:~# curl -I localhost HTTP/1.1 200 OK Server: openresty/1.21.4.1 Date: Sun, 09 Oct 2022 14:04:10 GMT Content-Type: text/html Content-Length: 1097 Last-Modified: Tue, 17 May 2022 03:51:45 GMT Connection: keep-alive ETag: "62831bd1-449" Accept-Ranges: bytes
也可以打開瀏覽器 ,訪問服務(wù)器ip,查看頁面驗(yàn)證。
參考鏈接
到此這篇關(guān)于在Debian11上安裝Openresty服務(wù)(Nginx+Lua)的文章就介紹到這了,更多相關(guān)Debian安裝Openresty服務(wù)內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!
