homebrew安裝
執行install.sh安裝腳本
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
可能出現的問題:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
原因:raw.githubusercontent.com網站連接不上
解決辦法:
查詢raw.githubusercontent.com對應ip並將映射添加到hosts文件中:
1.使用https://www.ip138.com查詢ip
2.將香港對應的ip提交到/etc/hosts文件中
sudo vi /etc/hosts
// 添加下面一行並保存
151.101.76.133 raw.githubusercontent.com
重新執行第一步安裝命令,可進行安裝
使用brew help
出現相關參數即說明安裝成功。
更換鏡像
更換原鏡像爲中科大鏡像
中科大鏡像網站
對於 bash 用戶:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
對於 zsh 用戶:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
這裏將HOMEBREW_BOTTLE_DOMAIN對應的地址變量寫入全局配置文件中。
使用export -p
查看配置
➜ ~ export -p
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
使用brew update
命令查看安裝情況
➜ ~ brew update
Already up-to-date.
即完成安裝。
卸載
執行下列語句進行卸載
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
另外,需要自己排查
/usr/local/Homebrew等目錄,手動進行刪除。