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
相关推荐
出了名的洗发水14 小时前
mac设置共享文件,win用户也可以访问
macos
superbadguy14 小时前
Mac新手入坑
macos
我寄人间雪满头丶14 小时前
GitHub 私有仓库 SSH 访问配置 SOP(Mac / Windows 通用)
macos·ssh·github
2501_9159184115 小时前
iOS App 测试方法,Xcode、TestFlight与克魔(KeyMob)等工具组合使用
android·macos·ios·小程序·uni-app·iphone·xcode
新手村领路人17 小时前
macos如何查看修改系统变量或用户变量
macos
旭日跑马踏云飞17 小时前
【本地玩AI】在macOS+AppleSilicon安装ComfyUI
人工智能·macos
旭日跑马踏云飞18 小时前
【向日葵】macOS连接windows时剪贴板不生效
macos
CrankZ18 小时前
[开源] 软软启动台 - 支持 Windows 和 macOS 的软件启动台(Launchpad)
macos
七夜zippoe19 小时前
Python多线程性能优化实战:突破GIL限制的高性能并发编程指南
python·macos·多线程·读写锁·gil·rcu
weixin_4624462320 小时前
使用 pip3 一键卸载当前环境中所有已安装的 Python 包(Linux / macOS / Windows)
linux·python·macos