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 执行下面这个

css 复制代码
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

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

css 复制代码
brew update

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

css 复制代码
brew doctor

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

css 复制代码
brew update-reset

再更新

css 复制代码
brew update

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

css 复制代码
cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-core
brew upgrade

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

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

最后执行

css 复制代码
brew update

安装Nginx

安装prce

css 复制代码
brew install pcre​​

安装zlib

css 复制代码
brew install zlib​​

安装openssl

css 复制代码
brew install openssl​​

下载Nginx

css 复制代码
brew install nginx

启动nginx

css 复制代码
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

相关推荐
徐子童几秒前
基于微服务的在线判题系统重点总结
java·微服务·架构
青衫码上行8 分钟前
【从0开始学习Java | 第21篇】网络编程综合练习
java·网络·学习
黑马金牌编程18 分钟前
Jenkins的Linux与window部署方式
linux·运维·windows·jenkins·持续集成·cicd
web安全工具库23 分钟前
告别刀耕火种:用 Makefile 自动化 C 语言项目编译
linux·运维·c语言·开发语言·数据库·算法·自动化
金纬软件126 分钟前
电脑监控软件有哪些?企业监控软件应该怎么选?
大数据·运维
DechinPhy30 分钟前
Ubuntu挂载新硬盘
linux·运维·服务器·ubuntu
lht63193561233 分钟前
Ubuntu Server 系统安装图形界面远程工具(RDP)
linux·运维·ubuntu
失心疯_202337 分钟前
PyQt开发_小学学习辅助工具
学习·pyqt
鸽鸽程序猿43 分钟前
【项目】【抽奖系统】注册功能实现
java·开发语言
我的xiaodoujiao1 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 18--测试框架Pytest基础 2--插件和参数化
python·学习·测试工具·pytest