Homebrew
官网 - https://brew.sh
官方文档 - https://docs.brew.sh
清华大学镜像 - https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
安装
bash
# ----------------------------------------------------------------------------------------------------------------------
# 安装
# ----------------------------------------------------------------------------------------------------------------------
# 清华大学
export HOMEBREW_BREW_GIT_REMOTE=https://mirrors.aliyun.com/homebrew/brew.git
export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.aliyun.com/homebrew/homebrew-core.git
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
# 阿里云
export HOMEBREW_BREW_GIT_REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
# 中科大
export HOMEBREW_BREW_GIT_REMOTE=https://mirrors.ustc.edu.cn/brew.git
export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.ustc.edu.cn/homebrew-core.git
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
#
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"
# ----------------------------------------------------------------------------------------------------------------------
# 卸载
# ----------------------------------------------------------------------------------------------------------------------
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/uninstall.sh)"
# ------------------------------------------------------------------------------------------------------------
# 更新
# ------------------------------------------------------------------------------------------------------------
brew outdated
brew update
brew update --verbose
brew upgrade
brew upgrade --cask $(brew list --cask)
#
brew tap homebrew/cask
brew tap homebrew/cask-drivers
brew tap homebrew/cask-fonts
brew tap homebrew/cask-versions
# 常用基础工具
brew install sevenzip
brew install openssl
brew install erlang
brew install git
brew install crypto
brew install pkg-config
brew install imagemagick
brew install vips
brew install ios-deploy
brew install ruby
brew install mysql
brew install redis
brew install rabbitmq
brew install php
brew install nginx
brew install postgresql@17
# mongodb
brew tap mongodb/brew
brew install mongodb-community
# tools
brew install zed
brew install sequel-ace
# tools - cask
brew install --cask dbeaver-community
brew install --cask warp
brew install --cask powershell
brew install --cask applite
# 基础服务
brew services start php
brew services start mysql
brew services start redis
brew services start rabbitmq
brew services start nginx
brew services start postgresql@17
brew services start mongodb-community
# 重启服务
sudo brew services restart nginx
brew services restart php
brew services restart redis
brew services restart mysql
brew services restart postgresql@17
brew services restart rabbitmq
brew services restart mongodb-community
brew services restart mongodb/brew/mongodb-community
# 列出所有服务
brew services list
# 显示安装路径
# MacOS - /opt/homebrew
# Linux - /home/linuxbrew/.linuxbrew
brew --prefix
# 查看下载路径
brew --cache
#
brew uninstall rabbitmq
brew uninstall wget
brew uninstall node@14
brew uninstall node@16
brew uninstall node@18
brew uninstall python@3.9
brew uninstall postgresql@17
FAQ
XZ
Homebrew版本太低了,不兼容新版的XZ导致安装出错
bash
Error: xz: undefined method `deny_network_access!' for Formulary::FormulaNamespacea8b7b798f9dedacccefb9c2c256d10d4::Xz:Class
到官网直接下载最新版本
https://github.com/tukaani-project/xz/releases/tag/v5.6.3
bash
# https://github.com/tukaani-project/xz/releases/download/v5.6.3/xz-5.6.3.tar.gz
# 解压缩后编译安装
tar xfv xz-5.6.3.tar.gz
cd xz-5.6.3
./configure --prefix=/usr/local/Cellar
make
make install
# 重建Brew链接
mkdir -p /usr/local/Cellar/xz/5.6.3/bin
ln -s /usr/local/Cellar/bin/xz /usr/local/Cellar/xz/5.6.3/bin
cd /usr/local/Cellar/xz/5.6.3
brew unlink xz
brew link --overwrite --force xz