跳转到主内容
新派编程网 - 新潮编程理念,全新技术课堂!

nginx+lua+redis 使用方法

1、 安装建议下载openresty ,包比较全,安装简单方便; 下载地址 http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz 2、编译安装
tar xzvf ngx_openresty-1.7.10.1.tar.gz cd ngx_openresty-1.7.10.1 ./configure --with-luajit make make install
3、修改 nginx config -  /usr/local/openresty/nginx/conf/nginx.conf # http段内添加下面引入redis支持: lua_package_path "/home/ngx_openresty-1.7.10.1/bundle/lua-resty-redis-0.20/lib/resty/?.lua;;"; #关闭lua脚本缓存,使得每次调用加载脚本,脚本修改不需要重启nginx lua_code_cache off; 4. nginx lua脚本使用方法 config文件内执行脚本 Nginx 在宝塔面板中轻松管理Nginx高性能Web服务器。提供可视化配置反向代理、负载均衡、SSL证书及HTTP缓存功能,一键优化高并发性能,助您高效搭建稳定、快速的网站运行环境。 下载 #lua script excute in this config location /lua{ set $test "hello world."; content_by_lua ' ngx.header.content_type = "text/plain"; ngx.say(ngx.var.test); '; } 外部lua脚本文件调用 location /extlua{ content_by_lua_file /home/lua_script/redis_test.lua; } 5、curl测试get post请求方法 get请求: curl  "http:/127.0.0.1/lua?id=1&name=pop" post 请求: curl -d "id=1&age=20"  "http://127.0.0.1/extlua" 多个参数url地址要加双引号 以上就介绍了nginx+lua+redis 使用方法,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关文章