root@vultr:/usr/local/nginx# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
3.执行命令 nginx -s reload 重载下 nginx 服务。
root@vultr:/usr/local/nginx# nginx -s reload
4.在浏览器中输入: test.damo.com/lua ,查看能否访问,如:
将 lua 代码单独写在一个文件中,然后 nginx 调用
1.在 nginx 安装目录下创建 lua 目录,用于存放 lua 脚本文件:
mkdir /usr/local/nginx/lua
2.在创建的 lua 目录下新建 lua 脚本文件 test.lua,内容为:
ngx.say("This is test lua");
4.编辑测试的域名文件 test.damo.com.conf,将其修改成:
server { listen 80; listen 443 ssl; server_name test.damo.com;
root@vultr:/usr/local/nginx# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful