1.配置lua的环境变量
2.打开openresty文件夹C:\Users\zhangjinqiang\Desktop\openresty-1.15.8.2-win64\conf\nginx.conf里的lua_package路径换成openresty安装路径
3.打开C:\Users\zhangjinqiang\Desktop\openresty-1.15.8.2-win64\conf\lua.conf将源代码替换
通过浏览器访问端口号9098/访问地址名即可运行
lua_shared_dict my_cache 128m;
server {
listen 9098;
server_name localhost;
location / {
default_type text/html;
content_by_lua_block {
local name=1000
ngx.say(name)
}
}
location /myweb {
default_type text/html;
content_by_lua_file C:/Users/zhangjinqiang/Desktop/test/myweb.lua;
}
location /mydb {
default_type text/html;
content_by_lua_file C:/Users/zhangjinqiang/Desktop/test/mydb.lua;
}
location /mysave {
default_type text/html;
content_by_lua_file C:/Users/zhangjinqiang/Desktop/test/mysave.lua;
}
location /myread {
default_type text/html;
content_by_lua_file C:/Users/zhangjinqiang/Desktop/test/myread.lua;
}
location /myadd {
default_type text/html;
content_by_lua_file C:/Users/zhangjinqiang/Desktop/test/myadd.lua;
}
}