zl程序教程

您现在的位置是:首页 >  其它

当前栏目

homebrew 常用命令

常用命令 Homebrew
2023-09-11 14:18:27 时间

1. brew 简介
2. 常用命令
3. 镜像配置
 

1. brew 简介


使用 brew 安装的软件,其安装位置和配置文件都存放在固定的目录

安装位置: /opt/homebrew/Cellar

配置文件: /opt/homebrew/etc

2. 常用命令


基础命令

命令描述
brew -v查看当前 homebrew 版本号
brew list列出已安装的软件
brew search 关键字根据关键字查找可安装的软件
brew outdated查看可更新的软件
brew info softwareName查看某个软件的详细信息
brew upgrade softwareName升级某个软件的详细信息

brew install、brew uninstall

 
  1. brew install redis
  2. brew install nginx
  3. brew install php@7.2
  4. // 卸载通过brew install安装的软件
  5. brew uninstall redis

brew serivces 命令

brew serivces 命令是专门用来管理通过 homebrew 安装的各类服务的

 
  1. // 查看所有服务及它们各自的运行状态
  2. brew services list
  3. // 启动服务
  4. brew services start redis
  5. // 停止服务
  6. brew services stop redis
  7. // 重启服务
  8. brew services restart redis

3. 镜像配置


查看镜像配置

阿里云镜像配置 (zsh 终端)

 
  1. # 替换brew.git:
  2. cd "$(brew --repo)"
  3. git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
  4. # 替换homebrew-core.git:
  5. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
  6. git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
  7. # 应用生效
  8. brew update
  9. # 替换homebrew-bottles:
  10. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
  11. source ~/.zshrc