自学内容网 自学内容网

mac安装openresty

官方地址:https://openresty.org/cn/download.html

brew update
brew install pcre openssl

下载源码

https://openresty.org/download/openresty-1.25.3.1.tar.gz

解压源码

tar -zxvf openresty-1.25.3.1.tar.gz

进入解压后的目录

./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

设置环境变量

export PATH=/opt/openresty/nginx/sbin:$PATH
export PATH=/opt/openresty/bin:$PATH

查看配置信息

openresty -V
nginx -V

创建测试文件目录

/Users/aaa/Documents/warehouse/openrestry/
/Users/aaa/Documents/warehouse/openrestry/conf
/Users/aaa/Documents/warehouse/openrestry/log

新建配置文件
openrestry/conf/nginx.conf

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服务

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  

测试结果

curl 127.0.0.1:8080
<h2>hello</h2>

关闭服务

nginx -p ./ -s stop

原文地址:https://blog.csdn.net/zzw_17600691357/article/details/136991383

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!