官方网站:https://openresty.org

mac下安装

1
brew install openresty/brew/openresty

创建工作目录

1
2
mkdir -p ~/code/openrestycode/logs
mkdir -p ~/code/openrestycode/conf

编写nginx.conf文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
worker_processes  1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}

启动nginx服务

1
2
cd ~/code/openrestycode
nginx -p . -c conf/nginx.conf