nginx安装lua模块
2016-04-12 11:09
411 查看
1、下载相应的nginx版本,http://nginx.org/en/download.html,安装过程略
2、安装lua或者luajit,http://luajit.org/download.html
yum install lua -y
3、下载模块https://github.com/openresty/lua-nginx-module/tags https://github.com/simpl/ngx_devel_kit/releases/tag/v0.3.0rc1
4、安装模块
tar -xzvf lua-nginx-module-0.10.2.tar.gz
tar -xzvf ngx_devel_kit-0.3.0rc1.tar.gz
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_secure_link_module --with-http_sub_module --add-module=../ngx_devel_kit-0.3.0rc1 --add-module=../lua-nginx-module-0.10.2
make
make install
5、测试lua脚本
在nginx.conf的server中添加如下内容
location /hello {
default_type "text/plain";
content_by_lua 'ngx.say("hello, lua")';
}
启动nginx会报 如下错误
./sbin/nginx: error while loading shared libraries:libluajit-5.1.so.2: cannot open shared object file: No such file or directory
此类问题通常使用ldconfig命令就能解决:
echo "/usr/local/lib" >/etc/ld.so.conf.d/lua.conf
ldconfig
重启nginx
访问http://127.0.0.1/hello 页面返回hello lua即安装成功
6、lua访问redis
下载https://github.com/agentzh/lua-resty-redis.git
将lib中的resty 复制到/usr/local/config/nginx/
lua_package_path "/usr/local/nginx/conf/resty/?.lua;;";
2、安装lua或者luajit,http://luajit.org/download.html
yum install lua -y
3、下载模块https://github.com/openresty/lua-nginx-module/tags https://github.com/simpl/ngx_devel_kit/releases/tag/v0.3.0rc1
4、安装模块
tar -xzvf lua-nginx-module-0.10.2.tar.gz
tar -xzvf ngx_devel_kit-0.3.0rc1.tar.gz
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_secure_link_module --with-http_sub_module --add-module=../ngx_devel_kit-0.3.0rc1 --add-module=../lua-nginx-module-0.10.2
make
make install
5、测试lua脚本
在nginx.conf的server中添加如下内容
location /hello {
default_type "text/plain";
content_by_lua 'ngx.say("hello, lua")';
}
启动nginx会报 如下错误
./sbin/nginx: error while loading shared libraries:libluajit-5.1.so.2: cannot open shared object file: No such file or directory
此类问题通常使用ldconfig命令就能解决:
echo "/usr/local/lib" >/etc/ld.so.conf.d/lua.conf
ldconfig
重启nginx
访问http://127.0.0.1/hello 页面返回hello lua即安装成功
6、lua访问redis
下载https://github.com/agentzh/lua-resty-redis.git
将lib中的resty 复制到/usr/local/config/nginx/
lua_package_path "/usr/local/nginx/conf/resty/?.lua;;";
相关文章推荐
- nginx rewrite 指令last break区别最详细的解释
- nginx windows No mapping for the Unicode character...
- Nginx的Rewrite正则表达式,匹配非某单词
- 在Nginx服务器中设置多个站点
- Linux(CentOS)系统下设置nginx开机自启动
- Nginx_handler模块发开(hello模块结构解析)
- 深入NGINX:我们如何设计它的性能和扩展性
- NGINX源代码剖析 之 CPU绑定(CPU亲和性)
- centos7 nginx安装
- nginx配置成服务
- 如何利用Nginx的缓冲、缓存优化提升性能
- Net分布式系统之三:Keepalived+LVS+Nginx负载均衡之高可用
- nginx gzip开启与配置
- Nginx学习笔记--Nginx图片缩略图,水印处理模块
- [Nginx 2] form表单提交,图片上传
- [Nginx 2] form表单提交,图片上传
- Nginx探索五
- Nginx服务器
- Nginx探索四
- Nginx探索三