openresty 第一个程序

修改nginx配置文件,默认路径在:

/usr/local/openresty/nginx/conf/nginx.conf

修改后的文件如下图所示

openresty 第一个程序

 

content_by_lua                  指定一句lua代码

content_by_lua_file            指定lua对应的文件,即在指定的文件下编写lua代码

content_by_lua_block        指定lua代码块,通过一对{}包裹起来,这里面是lua代码

ngx.say();  这个可以向浏览器输出内容。

 

校验修改后的nginx配置文件是否正确

nginx -t

 

重启nginx

nginx -s reload

 

通过浏览器访问

http://localhost/lua

http://localhost/lf

http://localhost/lb