一、Homebrew是什么
Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷,在我看来,类似于windows下的软件管家。
官网地址:https://brew.sh/
官方介绍:Homebrew installs the stuff you need that Apple didn’t.
用来下载那些你需要的但苹果系统没有的东西
二、Homebrew 安装
Homebrew 依赖于Xcode Command Line Tools,所以需先执行:
xcode-select --install
然后在命令行中运行该条命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装成功后 运行brew doctor 检查安装是否正常
➜ ~ brew doctor
Your system is ready to brew.
二、Homebrew 使用
//查看homebrew版本
➜ ~ brew -v
Homebrew 1.7.1
Homebrew/homebrew-core (git revision bda60; last commit 2018-08-13)
//查看帮助
brew -h
//安装、卸载、更新一个包 安装git
brew install/uninstall/upgrade <package_name>
//查看任意包信息 会显示详细配置信息
brew info <package_name>
//更新 Homebrew 在服务器端上的包目录
brew update
//清理旧版本的包缓存
brew cleanup
//查看所有你已安装的包(--versions 控制是否带版本号)
brew list --versions
//查看所有你安装的服务
brew services list
//启动或关闭一项你安装的服务
brew services start/stop mysql/php@7.0/nginx
//绑定解绑某个服务
brew link php@7.0
brew unlink php@7.0
三、常用小知识
基于brew安装的所有软件及其依赖均会安装到目录/usr/local/Cellar
有些应用会自动创建软链接放在/usr/bin或者/usr/sbin,同时也会将整个文件夹放在/usr/local
可以使用brew list 软件名确定安装位置
➜ ~ brew list php@7.0
/usr/local/Cellar/php@7.0/7.0.29_1/.bottle/etc/ (4 files)