nginx lua redis 配置安裝

2021-08-26 09:45:10 字數 2269 閱讀 7379

因為用openrsty也可以不用安裝所有模組都能用,但是為了更純淨些,就用nginx安裝自己需要的模組。

需要的模組為:

luajit-2.0.2.tar.gz?? echo-nginx-module-0.46.tar.gz?? lua-redis-parser-0.10.tar.gz?? redis2-nginx-module-0.10.tar.gz

lua-cjson-2.1.0.tar.gz?? lua-nginx-module-0.8.6.tar.gz?? nginx-1.4.2.tar.gz?? xss-nginx-module-0.03.tar.gz? pcre-8.10.tar.bz2

首先安裝luajit-2.0.2:

tar zxvf? luajit-2.0.2.tar.gz

cd? luajit-2.0.2

make

make install

然後裝pcre

tar xvf pcre-8.10.tar.bz2

./configure

make

make install

然後把其他模組都解壓,進入nginx-1.4.2下

export luajit_lib=/usr/local/lib

export luajit_inc=/usr/local/include/luajit-2.0

./configure --prefix=/usr/local/nginx --add-module=/usr/local/lua-nginx-module-0.8.6 --add-module=/usr/local/xss-nginx-module-0.03 --add-module=/usr/local/redis2-nginx-module-0.10 --add-module=/usr/local/echo-nginx-module-0.46

make

make install

當執行的時候報錯:

./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: no such file or directory

需要ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

這個時候啟動nginx,執行lua測試 會報

lua entry thread aborted: runtime error: /usr/local/nginx/conf/getdata.lua:1: module 'redis.parser' not found:

需要裝lua-redis-parser-0.10.tar.gz

命令:cd lua-redis-parser-0.10

export lua_include_dir=/usr/local/include/luajit-2.0/

gmake cc=gcc

make install cc=gcc

這回在執行lua測試會報:

2013/08/23 14:57:22 [error] 30574#0: *6 lua entry thread aborted: runtime error: /usr/local/nginx/conf/getdata.lua:2: module 'cjson' not found:

??????? no field package.preload['cjson']

明顯我的cjson也沒有裝,接下來裝lua-cjson-2.1.0.tar.gz ,解壓進入目錄:

make install

安裝會出現錯誤:

cc -c -o3 -wall -pedantic -dndebug? -i/usr/local/include -fpic -o lua_cjson.o lua_cjson.c

lua_cjson.c:43:17: error: lua.h: no such file or directory

lua_cjson.c:44:21: error: lauxlib.h: no such file or directory

然後我檢視vi makefile

加入:

lua_include_dir =?? $(prefix)/include 在這個後面加上luajit-2.0

變為 lua_include_dir =?? $(prefix)/include/luajit-2.0

則就找到了

再執行:

make install

這樣都裝完了。

nginx lua redis 使用方法

2 編譯安裝 tar xzvf ngx openresty 1.7.10.1.tar.gz cd ngx openresty 1.7.10.1 configure with luajit make make install3 修改nginx config usr local openresty ng...

nginx lua redis 防刷和限流

防刷的概念 防刷的目的是為了防止有些ip來爬去我們的網頁,獲取我們的 等資訊。不像普通的搜尋引擎,這種爬去行為我們經過統計最高每秒300次訪問,平均每秒266次訪問。由於我們的 的頁面都在cdn上,導致我們的cdn流量會定時冒尖。為了防止這種情況,打算將網頁頁面的訪問從cdn切回主站。同時開啟防刷功...

02nginx lua redis實現廣告快取

需要在頁面上顯示廣告的資訊 2.2.1 openresty介紹 openresty 又稱 ngx openresty 是乙個基於 nginx 的可伸縮的 web 平台,由中國人章亦春發起,提供了很多高質量的第三方模組。openresty 簡單理解,就相當於封裝了nginx,並且整合了lua指令碼,開...