OpenResty 將 LuaJIT 整合進 Nginx,讓開發者用 Lua 編寫高效能邏輯,廣泛用於 API 閘道、WAF、動態頁面渲染。本文記錄依賴安裝、原始碼編譯與常用配置選項。
# Debian/Ubuntu
apt-get update && apt-get install -y libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make
# CentOS/RHEL/Fedora
yum install -y readline-devel pcre-devel openssl-devel gcc make perl
wget https://openresty.org/download/openresty-1.25.3.1.tar.gz
tar xzf openresty-1.25.3.1.tar.gz
cd openresty-1.25.3.1
./configure --with-luajit
make -j$(nproc)
make install
# 預設安裝至 /usr/local/openresty
| 選項 | 說明 |
|---|---|
--prefix=/opt/openresty | 自訂安裝路徑 |
--with-luajit | 啟用 LuaJIT(預設開啟) |
--without-http_redis2_module | 排除不需模組減小體積 |
--with-http_iconv_module | 支援字元編碼轉換 |
--with-http_postgres_module | 內建 PostgreSQL 驅動 |
-jN | 並行編譯加速 |