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
相关推荐
2501_927541094 小时前
CameraBag Mac英文 照片视频滤镜编辑工具
macos
uiop_uiop_uiop7 小时前
iOS arm64e hook MGCopyAnswer got Crash or Only Partial results got hooked
macos·ios·cocoa
私人珍藏库10 小时前
[Mac] Unclutter 2.2.15 Mac上的文件暂存 智能剪贴板历史记录管理器工具
macos
哈茶真的c10 小时前
【Mac】开发环境使用/维护
macos
醇氧12 小时前
mac 安装 LibreOffice
macos
马拉萨的春天13 小时前
iOS中如果一个大图500M直接加载显示会崩溃,那么如何设置加载显示呢?
macos·ios·cocoa
AiXed14 小时前
PC微信WDA算法
前端·javascript·macos
刘晓倩1 天前
Docker Desktop(Windows/Mac)零外网部署 Dify 极简指南
macos·docker·容器
gcygeeker1 天前
解决 Mac 迁移数据后用户目录无权限问题
macos
todoitbo1 天前
Rust新手第一课:Mac环境搭建踩坑记录
开发语言·macos·rust