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 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
甜于酸12 小时前
MuMu模拟器Pro for Mac 安卓手机平板模拟器
android·macos·智能手机
渔夫阿布13 小时前
在MAC上面通过HomeBrew安装node和npm@指定版本
前端·macos·npm
waicsdn_haha14 小时前
TeX Live 2025 最新版安装与中文环境配置全教程(Windows/Mac/Linux)
linux·windows·macos·论文笔记·sublime text·mdk·嵌入式开发工具
xinyu39118 小时前
iOS Framework代码中加载图片资源
macos·ios·cocoa
励志前端小黑哥20 小时前
brew search报错,xcrun:error:invalid active developer path CommandLineTools
macos
至天1 天前
MacPorts 创建自定义 Portfile 安装 RoadRunner
macos·安装·macports·roadrunner·portfile
南瓜胖胖2 天前
【如何提取现有seismic unix文件为头文件和道数据文件】
macos·unix·mac
南瓜胖胖3 天前
【关于seisimic unix中使用suedit指令无法保存问题】
macos·unix·seismic unix