因为用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
这样都装完了。