天天看點

如何安裝nginx_lua_module子產品

摘要:

本文記錄如何安裝ngx_lua子產品

nginx_lua_module是由淘寶的工程師清無(王曉哲)和春來(章亦春)所開發的nginx第三方子產品,它能将lua語言嵌入到nginx配置中,進而使用lua就極大增強了nginx的能力

<a href="http://wiki.nginx.org/httpluamodule">http://wiki.nginx.org/httpluamodule</a>

正文:

1 下載下傳luajit 2.0并安裝

<a href="http://luajit.org/download.html">http://luajit.org/download.html</a>

我是直接使用源碼make &amp;&amp; make install

是以lib和include是直接放在/usr/local/lib和usr/local/include

2 下載下傳nginx源碼,解壓

注意版本号,如果機子上已經裝了nginx,不想更新的話,請使用/to/nginx/sbin/nginx –v

來檢視版本号

5 進入nginx源碼檔案夾

cd nginx-1.0.11/

6 導入環境變量,編譯

export luajit_lib=/usr/local/lib    #這個很有可能不一樣 

export luajit_inc=/usr/local/include/luajit-2.0  #這個很有可能不一樣

./configure --prefix=/opt/nginx \    #nginx的安裝路徑 

--add-module=/path/to/ngx_devel_kit \   #ngx_devel_kit 的源碼路徑 

--add-module=/path/to/lua-nginx-module  #nginx_lua_module 的源碼路徑

make -j2 

make install

7 測試是否成功:

nginxconfig中加入

location /hello { 

      default_type 'text/plain'; 

      content_by_lua 'ngx.say("hello, lua")'; 

}

使用/to/nginx/sbin/nginx –t 檢查nginx配置,此時應該沒有報錯

8 /to/nginx/sbin/nginx   #啟動nginx

或者/to/nginx/sbin/nginx –s reload #重新開機nginx

通路192.168.100.1/hello

會出現“hello,lua”

安裝成功!

----------------------

作者:yjf512(軒脈刃)

出處:http://www.cnblogs.com/yjf512/

本文版權歸yjf512和cnblog共有,歡迎轉載,但未經作者同意必須保留此段聲明

繼續閱讀