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
相关推荐
SoraLuna1 小时前
「Mac畅玩AIGC与多模态41」开发篇36 - 用 ArkTS 构建聚合搜索前端页面
前端·macos·aigc
有梦想的攻城狮2 小时前
mac本地docker镜像上传指定虚拟机
macos·docker·eureka
深井冰水4 小时前
Pycharm的终端执行allure命令出现command not found
macos·pycharm·接口自动化
黄昏贩卖机4 小时前
mac latex vscode 配置
ide·vscode·macos
莱茵不哈哈5 小时前
OpenResty 深度解析:构建高性能 Web 服务的终极方案
nginx·lua·kong·openresty·conf
亚林瓜子9 小时前
pyenv简单的Python版本管理器(macOS版)
开发语言·python·macos·pyenv
joinclear9 小时前
【问题记录】08 MAC电脑,安装HP打印机驱动,提示:此更新需要macOS版本15.0或更低版本
macos·hp打印机
SoraLuna20 小时前
「Mac畅玩AIGC与多模态40」开发篇35 - 用 Python 开发服务对接 SearxNG 与本地知识库
python·macos·aigc
WuYiCheng6661 天前
TLS 1.3黑魔法:从协议破解到极致性能调优
macos
piaoxue8201 天前
Mac上安装运行SynthTIGER
macos·语言模型