一场电闪与雷鸣的结合,
公司原有服务器已经配置好nginx,需要重新装载lua模块,哈哈哈,无法无法。
安装LUA模块需要以下
pcre ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
luajit http://luajit.org/download.html
ngx_devel_kit https://github.com/simpl/ngx_devel_kit/tags
lua_nginx_module https://github.com/openresty/lua-nginx-module/tags
luajit http://luajit.org/download.html
ngx_devel_kit https://github.com/simpl/ngx_devel_kit/tags
lua_nginx_module https://github.com/openresty/lua-nginx-module/tags
pcre yum install pcre-devel
luajit下载源码编译安装
ngx_devel_kit 与 lua_nginx_module 下载后放nginx源码里同nginx一同编译
编译过程
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-pcre --add-module=/usr/local/ngx_devel_kit --add-module=/usr/local/lua-nginx-module (这里的ngx_devel_kit 与 lua-nginx-module 放在/usr/local下了,理论应该放在nginx源码里)
接下来 :
make
当make完之后,不要make install,那样会直接覆盖掉现有的nginx服务,
将现有的nginx服务停掉,在新编译的nginx目录下:
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak //将原有的nginx给备份一下
cp ./objs/nginx /usr/local/nginx/sbin/ //将现有的nginx给拷贝过去
启动nginx 完成现有的nginx服务增加lua模块
nginx配置lua
1,在nginx中配置lua_package_path
lua_package_path "?.lua;/www/list.live.XXXX.com/?.lua;/usr/local/luajit/share/lua/5.1/?.lua;/usr/share/lua/5.1/?.lua";
然后在server中配置需要转发给lua的请求
location /get {
default_type text/plain;
content_by_lua_file /www/list.live.xxxx.com/get.lua;
}
location /image {
default_type text/plain;
content_by_lua_file /www/list.live.xxxx.com/image.lua;
}
location /room {
default_type text/plain;
content_by_lua_file /www/list.live.xxxx.com/room.lua;
}
default_type text/plain;
content_by_lua_file /www/list.live.xxxx.com/get.lua;
}
location /image {
default_type text/plain;
content_by_lua_file /www/list.live.xxxx.com/image.lua;
}
location /room {
default_type text/plain;
content_by_lua_file /www/list.live.xxxx.com/room.lua;
}
配置完成后重启即OK
遇到的问题:
./configure: error: ngx_http_lua_module requires the Lua library.
yum install lua-devel
make 的时候出现 ngx_http_lua_socket_udp.h:34: 错误:expected specifier-qualifi
解决办法:重新下载一个lua-nginx-module进行编译,我换用的是v0.10.7.tar.gz版本