一.NGINX和模块
LuaJIT-2.0.3.tar.gz lua-nginx-module-0.9.12.tar.gz nginx-1.6.1.tar.gz ngx_devel_kit-0.2.19.tar.gz pcre-8.30.tar.gz
二.安装LuaJIT
cd LuaJIT-2.0.3
make && make install PREFIX=/opt/soft/luajit
export LUAJIT_INC=/opt/soft/luajit/include/luajit-2.0
export LUAJIT_LIB=/opt/soft/luajit/lib/
三.安装PCRE和NGINX
cd pcre-8.30
./configure --prefix=/opt/soft/pcre && make && make install
cd nginx-1.6.1
./configure --prefix=/opt/soft/nginx --add-module=../ngx_devel_kit-0.2.19 --add-module=../lua-nginx-module-0.9.12 --with-pcre=../pcre-8.30 --with-ld-opt="-Wl,-rpath,$LUAJIT_LIB"
make && make install
四.配置nginx和启动nginx
[root@localhost soft]# /opt/soft/nginx/sbin/nginx
#/opt/soft/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
#报错,使用ldconfig来解决
#[root@localhost soft]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
#[root@localhost soft]# ldconfig
[root@localhost soft]# /opt/soft/nginx/sbin/nginx
这样就能正常启动了。。。
修改NGINX配置文件(在NGINX.CONF里增加)
location /lua {
set $test "hello, This is test!";
content_by_lua ‘
ngx.header.content_type = "text/plain";
ngx.say(ngx.var.test);
‘;
}
重新启动NGINX
/opt/soft/nginx/sbin/nginx -s reload
本文出自 “欧阳无情” 博客,请务必保留此出处http://wujuntl.blog.51cto.com/5136324/1552905
原文地址:http://wujuntl.blog.51cto.com/5136324/1552905