下載最新版:
https://openresty.org/download/openresty-1.13.6.2.tar.gz
安裝前的準備
您必須將這些庫 perl 5.6.1+
, libpcre
, libssl
安裝在您的電腦之中。 對於 Linux來說, 您需要確認使用 ldconfig
命令,讓其在您的系統環境路徑中能找到它們。
Fedora 和 RedHat 用戶
推薦您使用yum安裝以下的開發庫:
yum install pcre-devel openssl-devel gcc curl
構建 OpenResty
下載
從下載頁 Download下載最新的 OpenResty® 源碼包,並且像下面的示例一樣將其解壓:
tar -xzvf openresty-VERSION.tar.gz
VERSION
的地方替換成您下載的源碼包的版本號,比如說 0.8.54.6
。
./configure
然後在進入 openresty-VERSION/
目錄, 然後輸入以下命令配置:
./configure
默認, --prefix=/usr/local/openresty
程序會被安裝到/usr/local/openresty目錄。
您可以指定各種選項,比如
./configure --prefix=/opt/openresty \
--with-luajit \
--without-http_redis2_module \
--with-http_iconv_module \
--with-http_postgres_module
試着使用 ./configure --help
查看更多的選項。
配置文件(./configure script)運行出錯可以到 build/nginx-VERSION/objs/autoconf.err
找到。 VERSION
的地方必須與OpenResty版本號相對應, 比如 0.8.54.6
。
gmake
gmake install
啓動nginx
/usr/local/openresty/nginx/sbin/nginx
在地址欄輸入http://192.168.3.200/
進一步修改/usr/local/openresty/nginx/conf/nginx.conf,測試lua是否正常工作
重新加載nginx
/usr/local/openresty/nginx/sbin/nginx -s reload
驗證配置文件正確性
/usr/local/openresty/nginx/sbin/nginx -t
curl 驗證
curl http://localhost:8000/
輸出<p>welcome to lua world!</p>