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
相关推荐
清风细雨_林木木4 小时前
Mac 清理缓存,提高内存空间
macos·缓存
Macdo_cn4 小时前
Screen Wonders for Mac v3.3.1 3D屏保应用 支持M、Intel芯片
macos·音视频
秋窗719 小时前
Mac下Python版本管理,适用于pyenv不起作用的情况
开发语言·python·macos
獨枭1 天前
如何在 macOS 上配置 MySQL 环境变量
数据库·mysql·macos
清风细雨_林木木1 天前
解决 Mac 只显示文件大小,不显示目录大小
macos
蕴微轩1 天前
用openresty和lua实现壁纸投票功能
lua·openresty
9144062321 天前
xcode打包导出ipa
ide·macos·xcode
天荒地老笑话么2 天前
Mac安装配置Tomcat 8
java·macos·tomcat
xyc12112 天前
OpenResty
openresty
自娱自乐222 天前
mac下使用webstorm监听less文件自动生成wxss文件
macos·less·webstorm