1.安装
在官网根据自己的系统版本下载对应的安装包,我使用是windows,点击下图链接下载解压进行了
2.使用
cmd到所在的目录中,输入nginx.exe
启动,然后在浏览器访问localhost,出现“ Welcome to OpenResty”则成功
3.nginx嵌入lua
在Nginx的配置文件/conf/nginx.conf中使用content_by_lua或content_by_lua_file指令
- content_by_lua使用简单的脚本
打开nginx.conf,找到sever下localhost中配置
default_type text/html;
content_by_lua_block {
ngx.say("<p>hello, world</p>")
}
保存之后,使用nginx -s reload 重启nginx,刷新之后,下图所示
- content_by_lua_file引入lua文件
引入文件路径使用绝对路径或者相对路径从openresty-1.15.8.2-win64目录开始
4.常用命令
查看nginx版本号:nginx -V
启动nginx: start nginx
快速关闭nginx:nginx -s stop
正常关闭nginx:nginx -s quit
重启nginx:nginx -s reload
5.注意
如果没有启动成功,可能是默认80端口被占用