MacOS使用brew如何下载Nginx

首先,第一步切换源:

切换 brew.git 仓库地址:

cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

替换 homebrew-core.git 仓库地址: 

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

在替换 homebrew-bottles 访问地址之前首先检测本机是什么shell版本

echo $SHELL

输出 /bin/zsh 执行下面这个

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

如果是输出 /bin/bash 执行下面这个

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

在切换完上面各镜像后,执行下方指令查看是否成功

brew update

无法成功的话,执行下面一串代码

brew doctor

出现一系列问题之后继续走

brew update-reset

再更新

brew update

还是不行的话,就删除homebrew-core就可以了

cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-core
brew upgrade

使用brew upgrade会重新更新 homebrew-core。安装速度太慢的话马上让终端运行停下来,走下列指令

cd /usr/local/Homebrew/Library/Taps
mkdir homebrew
git clone git://mirrors.ustc.edu.cn/homebrew-core.git
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

最后执行

brew update

安装Nginx

安装prce

brew install pcre​​

安装zlib

brew install zlib​​

安装openssl

brew install openssl​​

下载Nginx

brew install nginx

启动nginx

sudo nginx

4 成果展示

最终激动人心的时刻到了。

在浏览器输入 http://localhost:8080/

Nginx相关操作指令
启动Nginx:sudo systemctl start nginx
停止Nginx:sudo systemctl stop nginx
重启Nginx:sudo systemctl restart nginx
查看Nginx状态:sudo systemctl status nginx
测试配置文件是否正确:sudo nginx -t
重新加载Nginx配置文件:sudo systemctl reload nginx
查看Nginx版本号:nginx -v
查看Nginx帮助文档:nginx -h

本文参考链接 ==》MacOS全套详细介绍如何下载Nginx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值