最近换了macbook pro,所以开始折腾mac os上的开发环境,记在这里方便自己和别人
Homebrew是什么
官网:http://mxcl.github.com/homebrew/ Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn’t include with OS X. 官方的解释非常明了,Homebrew是一个包管理器,用于在Mac上安装一些OS X没有的UNIX工具(比如著名的wget)。
换个说法,homebrew就像ubuntu的ape-get,同样的就像linux的yum,都是包管理器。
Homebrew将这些工具统统安装到了 /usr/local/Cellar 目录中,并在 /usr/local/bin 中创建符号链接。
Homebrew依赖github,安装如下:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
使用Homebrew
搜索软件:brew search 软件名,例:brew search tomcat
安装软件:brew install 软件名,例:brew install tomcat@7
卸载软件:brew uninstall 软件名,例:brew uninstall tomcat@7
使用search后,homebrew会列出所有相关的可供安装的软件,比如我运行 brew search tomcat, 等待一会会列出tomcat的多个版本,直接install tomcat@7 ,安装的是7_79版本
其他命令
brew list —列出已安装的软件
brew update —更新Homebrew
brew home *—用浏览器打开
brew info *—显示软件内容信息
brew deps * — 显示包依赖
brew server * —启动web服务器,可以通过浏览器访问http://localhost:4567/ 来同网页来管理包
brew -h brew —帮助
更快的使用Homebrew
从网上看了很多帖子,我都总结了,所以看这里就够了:
- coding.net的镜像
- 中科大的镜像
- 清华大学的镜像
CODING.NET(命令不对,待查)
另外2个是教育网,我们这些走出学校的码农连着还是慢,不如这个saas平台,做代码托管以及项目管理的saas产品
$ cd /usr/local && git remote set-url origin https://git.coding.net/homebrew/homebrew.git
$ cd $home && brew update
中科大
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 直接执行一下命令,会写入 ~/.bash_profile,如果想恢复,直接在.bash_profile注掉就可以了
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
#如果想恢复,注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。
清华大学(亲测,可用)
# 重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
# 重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
删除Homebrew
cd `brew –prefix`
rm -rf Cellar
brew prune
rm `git ls-files`
rm -rf Library .git .gitignore bin/brew
rm -rf [README.md](http://readme.md/) share/man/man1/brew
rm -rf Library/Homebrew Library/Aliases
rm -rf Library/Formula Library/Contributions
rm -rf ~/Library/Caches/Homebrew