Homebrew教程

2021-07-13  本文已影响0人  EugeneHeen

❀ 1 Homebrew是什么

Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。

❀ 2 官网

https://brew.sh/

❀ 3 Homebrew

※ 3.1 安装Homebrew

打开终端输入以下命令完成安装:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

或者使用国内镜像安装(推荐):

$ /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替换默认配置(解决国内下载慢,下面使用阿里源)

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个配置文件,添加的环境变量HOMEBREW_BOTTLE_DOMAIN

❀ 4 我们使用Homebrew来干什么?

※ 4.1 安装你所需要的系统软件

$ brew install wget

Homebrew会将软件包安装到独立目录/usr/local/Cellar,并将其文件软链接至 /usr/local

$ brew upgrade wget
$ brew remove wget
$ brew list
$ brew search wget
$ brew info wget

※ 4.2 Brew Services

brew services是一个非常强大的工具,可以用来管理各种服务的启停,有点像linux里面的services,非常方便,以elasticsearch为例:

$ brew install elasticsearch
$ brew services start elasticsearch
$ brew services stop elasticsearch
$ brew services restart elasticsearch
$ brew services list

brew services服务相关配置以及日志路径:

上一篇 下一篇

猜你喜欢

热点阅读