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
相关推荐
一只小白菜2 小时前
[特殊字符] 解决 Mac M5 芯片上 Ollama 运行报错:升级 macOS Tahoe 26.4.1 后恢复正常
macos
爱吃香蕉的阿豪1 天前
Mac 远程操作 Windows 开发:ZeroTier + JetBrains 实战指南
windows·macos·zerotoer
大嘴皮猴儿2 天前
从零开始学商品图翻译:小白也能快速掌握的多语言文字处理与上架技巧
大数据·ide·人工智能·macos·新媒体运营·xcode·自动翻译
空中海2 天前
第六章:iOS导航与路由系统
macos·ios·cocoa
空中海2 天前
第九章:iOS系统框架与能力
macos·ios·cocoa
大棉花哥哥2 天前
MAC下JADX+MCP+OpenCode自动APK逆向分析
macos·ai
空中海2 天前
第八章:iOS并发编程
macos·ios·cocoa
算是难了2 天前
macOS常用终端命令
macos
小码过河.2 天前
本地端侧GUI智能体自动化操作电脑Mano-P:macOS版本安装与使用全指南
macos·ai·自动化
空中海2 天前
第十章:iOS架构设计与工程化
macos·ios·cocoa