mac安装openresty

官方地址:https://openresty.org/cn/download.html

bash 复制代码
brew update
brew install pcre openssl

下载源码

bash 复制代码
https://openresty.org/download/openresty-1.25.3.1.tar.gz

解压源码

bash 复制代码
tar -zxvf openresty-1.25.3.1.tar.gz

进入解压后的目录

bash 复制代码
./configure --prefix=/opt/openresty --with-cc-opt="-I/usr/local/include" --with-luajit --without-http_redis2_module --with-ld-opt="-L/usr/local/lib"
make
sudo make install

设置环境变量

bash 复制代码
export PATH=/opt/openresty/nginx/sbin:$PATH
export PATH=/opt/openresty/bin:$PATH

查看配置信息

bash 复制代码
openresty -V
nginx -V

创建测试文件目录

bash 复制代码
/Users/aaa/Documents/warehouse/openrestry/
/Users/aaa/Documents/warehouse/openrestry/conf
/Users/aaa/Documents/warehouse/openrestry/log

新建配置文件

openrestry/conf/nginx.conf

bash 复制代码
worker_processes 1;
error_log log/error.log;

events {
    worker_connections 1024;
}

http {
    server {
        listen 8080;
        location / {
            default_type text/html;
            content_by_lua_block {
                ngx.say("<h2>hello</h2>")
            }
        }
    }
}

openrestry目录下启动nginx服务

bash 复制代码
nginx -p ./ -c conf/nginx.conf
ps -ef | grep nginx
nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;  
nginx: worker process  

测试结果

bash 复制代码
curl 127.0.0.1:8080
<h2>hello</h2>

关闭服务

bash 复制代码
nginx -p ./ -s stop
相关推荐
一个人旅程~1 小时前
Windows的6月份安全启动证书过期如何查看是否过期是否需要更新如何操作
windows·经验分享·macos·电脑
Gh0stX2 小时前
macOS Burp Suite Professional 激活指南
macos
会Tk矩阵群控的小木2 小时前
imessage虚拟机群发系统搭建:基于UTM+Frida的完整实现与海外社媒集成
macos·ios·objective-c·cocoa·开源软件·个人开发·tk矩阵
风吹夏回2 小时前
保姆级教程:Dify 本地一键部署(Windows/Mac 通用)
windows·macos
章老师说6 小时前
B站网关事故背后:OpenResty 与 Lua 的稳定性代价
nginx·云原生·负载均衡·lua·openresty
安静轨迹7 小时前
计算机网络三大核心数据表:MAC 地址表、ARP 表、路由表(深度通俗完整版)
网络·计算机网络·macos
一勺菠萝丶7 小时前
Mac Homebrew 更新卡住怎么办?如何更换国内源、查看进度和安装软件
macos
春波petal1 天前
Mac nvm 永久固定 Node 版本(新开终端自动生效)
macos·nvm
小宋10211 天前
Mina Meeting Assistant 新手极速上手指南
ide·macos·ai·xcode·mina
AI创界者1 天前
ComfyUI v8 极致整合包发布!Win/Mac 双平台完美适配 + 多卡并行加速,开启 AI 绘画新时代
人工智能·macos