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 天前
从零开始:JDK 在 Windows、macOS 和 Linux 上的下载、安装与环境变量配置
java·windows·macos
三劫散仙1 天前
mac m1上使用Kerberos访问远程linux hadoop集群的正确姿势
linux·hadoop·macos
@蓝眼睛1 天前
mac的m3芯片安装JDK8、JDK17
macos·jdk
彬彬醤1 天前
Mac怎么连接VPS?可以参考这几种方法
大数据·运维·服务器·数据库·线性代数·macos·矩阵
ka2x2 天前
Mac 电脑 IDEA 执行 Maven 出现 No route to host 问题
macos·maven·intellij-idea
易我数据恢复大师2 天前
如何在mac玩windows游戏?3个工具推荐,不用换电脑!
macos·mac·mac运行windows游戏·easeus os2go·mac玩windows游戏
@蓝眼睛2 天前
mac的m3芯片通过Homebrew安装git
git·macos
网络研究院2 天前
新的 SHAMOS MacOS 窃取程序利用单行终端命令攻击用户
macos·攻击·漏洞·用户
@蓝眼睛2 天前
mac的m3芯片安装mysql
mysql·macos
泓博2 天前
iOS打开开发者模式
macos·objective-c·cocoa