Mac下Homebrew安装


Homebrew 是什么

Homebrew是 mac的包管理器,仅需执行相应的命令,就能下载安装需要的软件包,可以省掉自己去下载、解压、拖拽(安装)等繁琐的步骤。 比如安装服务器 nginx,打开终端执行以下命令即可安装:

# brew.git
cd "$(brew --repo)" 
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# homebrew-bottles
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

# homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" 
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# homebrew-cask.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

重置为官方地址:

// 查询:
brew search 软件名

// 安装:
brew install 软件名

// 卸载:
brew uninstall 软件名

// 更新 Homebrew:
brew update 

// 查看 Homebrew 配置信息:
brew config 

 注:使用官方脚本同样会遇到uninstall地址无法访问问题,可以替换为下面脚本:

/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall)"
mac