? 1 Homebrew是什么
Homebrew
是一款Mac OS
平臺(tái)下的軟件包管理工具印衔,擁有安裝、卸載姥敛、更新奸焙、查看、搜索等很多實(shí)用的功能彤敛。簡(jiǎn)單的一條指令与帆,就可以實(shí)現(xiàn)包管理,而不用你關(guān)心各種依賴和文件路徑的情況墨榄,十分方便快捷玄糟。
? 2 官網(wǎng)
? 3 Homebrew
※ 3.1 安裝Homebrew
打開(kāi)終端
輸入以下命令完成安裝:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
或者使用國(guó)內(nèi)鏡像安裝(推薦):
$ /bin/zsh -c "$(curl -fsSL [https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh](https://links.jianshu.com/go?to=https%3A%2F%2Fgitee.com%2Fcunkai%2FHomebrewCN%2Fraw%2Fmaster%2FHomebrew.sh))"
※ 3.2 更新Homebrew
$ brew update
※ 3.3 查看Homebrew版本
$ brew -v
※ 3.4 查看Homebrew配置
$ brew config
※ 3.5 查看Homebrew幫助
$ brew -h
※ 3.6 Homebrew替換默認(rèn)配置(解決國(guó)內(nèi)下載慢,下面使用阿里源)
3.6.1 替換brew.git地址
- 替換
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
- 還原
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git
3.6.2 替換homebrew-core地址
- 替換
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
- 還原
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
3.6.3 替換homebrew-bottles地址
- 替換
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
- 還原
$ vi ~/.bash_profile
$ vi ~/.zshrc
分別刪除2
個(gè)配置文件袄秩,添加的環(huán)境變量HOMEBREW_BOTTLE_DOMAIN
阵翎。
? 4 我們使用Homebrew來(lái)干什么逢并?
※ 4.1 安裝你所需要的系統(tǒng)軟件
- 安裝軟件
$ brew install wget
Homebrew
會(huì)將軟件包安裝到獨(dú)立目錄/usr/local/Cellar
,并將其文件軟鏈接至 /usr/local
郭卫。
- 更新軟件
$ brew upgrade wget
- 卸載軟件
$ brew remove wget
- 列出當(dāng)前已安裝的軟件
$ brew list
- 查詢指定軟件砍聊,相關(guān)的可用軟件
$ brew search wget
- 查詢指定軟件的安裝信息
$ brew info wget
※ 4.2 Brew Services
brew services
是一個(gè)非常強(qiáng)大的工具,可以用來(lái)管理各種服務(wù)的啟停贰军,有點(diǎn)像linux
里面的services
玻蝌,非常方便,以elasticsearch
為例:
- 安裝elasticsearch
$ brew install elasticsearch
- 啟動(dòng)elasticsearch
$ brew services start elasticsearch
- 停止elasticsearch
$ brew services stop elasticsearch
- 重啟 elasticsearch
$ brew services restart elasticsearch
- 列出當(dāng)前的狀態(tài)
$ brew services list
brew services
服務(wù)相關(guān)配置以及日志路徑:
- 配置路徑:
/usr/local/etc/
词疼。 - 日志路徑:
/usr/local/var/log
俯树。