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
相关推荐
GentleDevin21 小时前
Mac 常用快捷键速查表
macos
GOU9221 小时前
5101实验
网络·macos
柯儿的天空1 天前
【OpenClaw 全面解析:从零到精通】第 005 篇:OpenClaw 在 macOS 上的安装与部署实战
人工智能·macos·自然语言处理·ai作画
@大迁世界1 天前
液态玻璃屏正在侵蚀你的电池
macos·ios·objective-c·cocoa
liangshanbo12151 天前
[特殊字符] macOS 上的 zoxide:智能目录跳转终极指南
macos·策略模式
pop_xiaoli1 天前
【iOS】类与对象底层
macos·ios·objective-c·cocoa·xcode
一招定胜负1 天前
视频转写+LLM分析:课堂录音自动化处理实现
macos·ios·xcode
坚果派·白晓明1 天前
在 macOS 中搭建鸿蒙 PC 三方库交叉编译开发环境
macos·华为·harmonyos
blackorbird1 天前
通过攻陷合法网站传播的新型iOS漏洞利用工具包DarkSword
macos·ios·objective-c·cocoa
ricky_fan2 天前
(OpenAI)Codex 安装、部署使用方式
python·macos·conda·vim