nginx+lua+redis 使用方法

WBOY
發布: 2016-08-08 09:24:39
原創
1161 人瀏覽過

1、 安裝建議下載openresty ,包裝比較全,安裝簡單方便;

       下載位址http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz

2、編譯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文件內執行腳本🠎 /lua{

            set $test "hello world.";

            content_by_lua '

             ngx.say(ngx.var.test);

            ';

        }


lua腳本檔案呼叫

        location /extlua{
            content_by_lua_file /home/lua_script/redis_test.luaa
; url  "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教程有興趣的朋友有所幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!