Tengine編譯安裝+lua+sticky模塊

一.兩個依賴包 yum的直接nginx

yum   yum –y install openssl openssl-devel prce prce-devel zlib zlib-develgit

沒有yum環境的,能夠源碼安裝:github

cd /usr/localbash

wget https://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gzcookie

tar  zxf  pcre-8.37.tar.gz負載均衡

cd pcre-8.37 && ./configure &&make&&make installui

wget http://www.openssl.org/source/openssl-1.0.1c.tar.gzlua

tar zxf openssl-1.0.1c.tar.gzspa

cd openssl-1.0.1c.tar.gz &&./config --prefix=/usr/local/openssl -fPIC no-gost no-shared no-zlib.net

make depend &&make install

wget http://www.zlib.net/zlib-1.2.11.tar.gz

tar zxf zlib-1.2.11.tar.gz

cd /usr/local/zlib-1.2.11 &&./configure

make && make install

二.而後安裝LuaJIT

mkdir /usr/local/modules   ###存放因此的第三方模塊目錄

cd /usr/local/modules

1.wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz

tar -zxvf LuaJIT-2.0.5.tar.gz

cd LuaJIT-2.0.5

make install PREFIX=/usr/local/LuaJIT

最後一行會輸出一下提示:

==== Successfully installed LuaJIT 2.0.5 to /usr/local/LuaJIT ====

vi /etc/profile   文件末尾加入環境變量

export LUAJIT_LIB=/usr/local/LuaJIT/lib

export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0

source /etc/profile

ln -s /usr/local/luajit/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2 #不增長這行,nginx啓動會報錯

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

wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz

tar -xzvf v0.3.0.tar.gz

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

wget https://github.com/openresty/lua-nginx-module/archive/v0.10.8.tar.gz

tar -xzvf v0.10.8.tar.gz

 

三.sticky模塊(cookie負載均衡,存在客戶端的)

wget https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/master.tar.gz

tar -zxf master.tar.gz

nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d.tar.gz(這個包是tengine sticky的擴展包) 

mv  nginx-goodies-nginx-sticky-module-ng-c78b7dd79d0d/ nginx-sticky

 

四.tengine安裝(nginx也是同樣)

tengine-2.1.1.tar.gz

tar zxf tengine-2.1.1.tar.gz

cd  tengine-2.1.1

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.37 --with-pcre-jit --with-zlib=/usr/local/zlib-1.2.11 --with-openssl=/usr/local/openssl-1.0.1c --with-http_sub_module --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module  --with-http_realip_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --add-module=/usr/local/modules/ngx_devel_kit-0.3.0 --add-module=/usr/local/modules/lua-nginx-module-0.10.8 --add-module=/usr/local/modules/nginx-sticky/ 

make

make install

安裝後: 

/usr/local/nginx/sbin/nginx -t   查看狀態

/usr/local/nginx/sbin/nginx     啓動nginx 

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

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

重啓nginx

訪問10.211.55.3/hello_lua會出現」hello, lua」表示lua安裝成功

相關文章
相關標籤/搜索