openresty mac 安装与使用,openrestymac


安装

brew update
brew install pcre openssl
  1. 安装
brew install homebrew/nginx/openresty
  1. 设置环境变量
PATH=/usr/local/opt/openresty/nginx/sbin:$PATH
export PATH

3.启动查看
查看版本信息

nginx -V

启动

nginx

常用命令

启动:nginx
停止:nginx -s stop   停止nginx也停止了openresty
重启:nginx -s reload
检验nginx配置是否正确: nginx -t

Hello World

  • 创建测试目录
mkdir ~/openresty-test ~/openresty-test/logs/ ~/openresty-test/conf/
  • 在conf文件下创建nginx.conf文件
worker_processes  1;
error_log logs/error.log;
events {
    worker_connections 1024;
}
http {
    server {
        listen 8088;
        location / {
            default_type text/html;
            content_by_lua '
                ngx.say("hello lua")
            ';
        }
    }
}
  • nginx -p ${pwd} -c conf/nginx.conf
  • 访问 http://localhost:8888

相关内容

    暂无相关文章