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
相关推荐
老蒋每日coding5 小时前
Node.js 安装指南(Mac 版本)
macos·node.js
AI玫瑰助手5 小时前
Python入门:Windows/macOS/Linux系统安装Python教程
windows·python·macos
智算菩萨5 小时前
OpenAI Codex 国内使用完全指南:Windows/macOS/Linux 三平台详细安装配置教程(现在最新的有gpt-5.3-codex和gpt-5.4)
linux·windows·gpt·macos·ai·ai编程·codex
AAI机器之心5 小时前
在 macOS 上本地部署 Ollama + LLaMA3(附教程)
人工智能·macos·langchain·llm·知识库·大模型部署
HSTK5 小时前
Mac上配置PlatformIO
macos
于慨1 天前
firecrawl
macos
vooy pktc1 天前
macOS安装Redis
数据库·redis·macos
A懿轩A1 天前
Ghostty:告别 Mac 毛坯终端,打造 2026 最丝滑的 Ghostty AI 开发驾驶舱——Claude Code 团队也在用
python·macos·策略模式
空中海1 天前
01. iOS 逆向基础、环境搭建与授权
macos·ios·cocoa
空中海1 天前
iOS LLDB 调试、Mach-O、Runtime 与二进制分析
macos·ios·cocoa