在Debian11上安裝Openresty服務(wù)(Nginx+Lua)的詳細(xì)教程
OpenResty 是一個基于 Nginx 與 Lua 的高性能 Web 平臺,其內(nèi)部集成了大量精良的 Lua 庫、第三方模塊以及大多數(shù)的依賴項(xiàng)。用于方便地搭建能夠處理超高并發(fā)、擴(kuò)展性極高的動態(tài) Web 應(yīng)用、Web 服務(wù)和動態(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)行下面的命令就可以添加我們的倉庫(每個系統(tǒng)只需要運(yùn)行一次):
步驟一:安裝導(dǎo)入 GPG 公鑰時(shí)所需的幾個依賴包(整個安裝過程完成后可以隨時(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 倉庫。
對于 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
而對于 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
這個包同時(shí)也推薦安裝 openresty-opm 和 openresty-restydoc 包,所以后面兩個包會缺省安裝上。
如果你不想自動關(guān)聯(lián)安裝,可以用下面方法關(guān)閉自動關(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 命令請求 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)證。
參考鏈接
https://wang123.net/a/linux-debian-install-openresty
https://openresty.org/cn/linux-packages.html
到此這篇關(guān)于在Debian11上安裝Openresty服務(wù)(Nginx+Lua)的文章就介紹到這了,更多相關(guān)Debian安裝Openresty服務(wù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Nginx反向代理出現(xiàn)502?Bad?Gateway問題解決
在配置Nginx反向代理時(shí)遇到502 Bad Gateway錯誤,經(jīng)過排查發(fā)現(xiàn)是SSL握手問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-10-10
Nginx配置srcache_nginx模塊搭配Redis建立緩存系統(tǒng)
這篇文章主要介紹了Nginx配置srcache_nginx模塊搭配Redis建立緩存系統(tǒng)的方法,文中關(guān)于Nginx模塊和Redis數(shù)據(jù)庫的安裝就不再說明了,這里只關(guān)注配置搭建階段,需要的朋友可以參考下2016-01-01
Nginx實(shí)現(xiàn)UDP四層轉(zhuǎn)發(fā)的過程
為了解決VPN連接速度慢的問題,可以通過Nginx實(shí)現(xiàn)UDP的四層轉(zhuǎn)發(fā),首先檢查Nginx是否安裝了with-stream模塊,然后修改nginx.conf配置文件進(jìn)行UDP端口的轉(zhuǎn)發(fā)設(shè)置,使用nginx-t檢查配置文件語法,無誤后重新加載Nginx,這樣通過國內(nèi)服務(wù)器中轉(zhuǎn),可以提升連接到國外服務(wù)器的速率2024-09-09
解決Nginx無法啟動 -10013: An attempt was
這篇文章主要給大家介紹了解決用nginx -t 發(fā)成Nginx無法啟動報(bào)錯10013: An attempt was made to access a socket in a way forbidden by its access permissions的問題,需要的朋友可以參考下2023-11-11
Nginx?403?forbidden錯誤的五種原因及詳細(xì)解決方法
這篇文章主要給大家介紹了關(guān)于Nginx?403?forbidden錯誤的五種原因及詳細(xì)解決方法,相信很多人對403 forbidden是什么意思有了大致的了解,那么當(dāng)我們遇到403 forbidden怎么解決呢,需要的朋友可以參考下2023-08-08
windows系統(tǒng)下關(guān)閉Nignx的多種方式總結(jié)
這篇文章主要給大家總結(jié)介紹了windows系統(tǒng)下關(guān)閉Nignx的多種方式, 在Windows中啟動Nginx是簡單的,但有許多小伙伴不會關(guān)閉,這里給大家介紹下,需要的朋友可以參考下2023-08-08

