小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Nginx安裝lua

 SmingPro 2017-02-15

Nginx安裝lua-nginx-module模塊

ngx_lua_module 是一個nginx http模塊,它把 lua 解析器內(nèi)嵌到 nginx,用來解析并執(zhí)行l(wèi)ua 語言編寫的網(wǎng)頁后臺腳本

特性很牛叉,可自行百度查看,這里主要是示范一下,如何在Nginx下安裝lua-nginx-module模塊

當(dāng)然,如果你之前沒有安裝過Nginx,而且嫌安裝麻煩,可直接下載openresty安裝簡單快捷,http:///cn/installation.html(阿里的大牛章亦春的作品,膜拜~~~)

1.下載安裝LuaJIT 2.1(2.0或者2.1都是支持的,官方推薦2.1):http:///download.html

cd /usr/local/src
wget http:///download/LuaJIT-2.1.0-beta2.tar.gz
tar zxf LuaJIT-2.1.0-beta2.tar.gz
cd LuaJIT-2.1.0-beta2
make PREFIX=/usr/local/luajit
make install PREFIX=/usr/local/luajit
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

2.下載ngx_devel_kit(NDK)模塊 :https://github.com/simpl/ngx_devel_kit/tags,不需要安裝

cd /usr/local/src
wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
tar -xzvf v0.2.19.tar.gz
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

3.下載最新的lua-nginx-module 模塊 :https://github.com/openresty/lua-nginx-module/tags,不需要安裝

cd /usr/local/src
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.2.tar.gz
tar -xzvf v0.10.2.tar.gz
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

4.nginx -V查看已經(jīng)編譯的配置

nginx -V
  • 1
  • 1

筆者的配置如下:

--prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-1.0.2h --with-pcre=../pcre-8.38 --with-pcre-jit --with-ld-opt=-ljemalloc --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.10.2
  • 1
  • 1

5.進入之前安裝nginx的解壓目錄,重新編譯安裝(在nginx -V得到的配置下,加入ngx_devel_kit-0.2.19和ua-nginx-module-0.10.2的目錄),最終的配置如下:

設(shè)置環(huán)境變量

export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1
  • 1
  • 2
  • 1
  • 2
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-1.0.2h --with-pcre=../pcre-8.38 --with-pcre-jit --with-ld-opt='-ljemalloc' --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib" --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.10.2
  • 1
  • 1

6.編譯安裝

make -j2
make install
  • 1
  • 2
  • 1
  • 2

7.查看是否編譯成功

在/usr/local/nginx/conf/nginx.conf中加入如下代碼:

location /hello_lua { 
      default_type 'text/plain'; 
      content_by_lua 'ngx.say("hello, lua")'; 
}
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

重啟nginx:

service nginx restart
  • 1
  • 1

訪問10.211.55.3/hello_lua會出現(xiàn)”hello, lua”表示安裝成功

hello, lua
  • 1
  • 1

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多