http://wiki.jikexueyuan.com/project/openresty/openresty/install_osx.html
1.brew 安装 openresty
$ brew tap homebrew/nginx
$ brew install homebrew/nginx/openresty
$ brew update
$ brew install pcre openssl
2.配置 openresty nginx 环境
export PATH=${PATH}:/usr/local/Cellar/openresty/1.13.6.2/nginx/sbin/
3.设置conf
mkdir ~/openresty-test ~/openresty-test/logs/ ~/openresty-test/conf/
4.在 conf 目录下创建一个文本文件作为配置文件,命名为 nginx.conf,文件内容如下:
worker_processes 1; #nginx worker 数量
error_log logs/error.log; #指定错误日志文件路径
events {
worker_connections 1024;
}
http {
server {
#监听端口,若你的8080端口已经被占用,则需要修改
listen 8080;
location / {
default_type text/html;
content_by_lua_block {
ngx.say("HelloWorld")
}
}
}
}
- 启动 openresty nginx
cd openresty-test
nginx -p `pwd`/ -c conf/nginx.conf
- 我们可以查看 nginx 进程是否存在,并通过访问 HTTP 页面查看应答内容。操作提示如下:
ps -ef | grep nginx
curl http://localhost:6699 -I
nginx -s reload
nginx -s stop
网友评论