2014年5月23日星期五

MAC_013:安装Homebrew

环境:MAC OS X 10.9.3

Homebrew之于MAC,就相当于yum之于RHEL。

Homebrew官网:http://brew.sh/index_zh-cn.html。

1. 安装
只需在终端中执行:ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
如果找不到上面的地址,试试这个:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

输出如下:

==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
/usr/local/etc
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/info
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin
/usr/local/etc
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/info

Press RETURN to continue or any other key to abort
按下回车键,开始下载并安装,这个过程有些慢,耐心等待下。

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin /usr/local/etc /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/info
Password:
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin /usr/local/etc /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/info
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 174662, done.
remote: Compressing objects: 100% (48636/48636), done.
remote: Total 174662 (delta 124888), reused 174648 (delta 124877)
Receiving objects: 100% (174662/174662), 33.81 MiB | 9.00 KiB/s, done.
Resolving deltas: 100% (124888/124888), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
HEAD is now at f550366 opengrm-ngram 1.2.1
==> Installation successful!
==> Next steps

Run `brew doctor` before you install anything

Run `brew help` to get started

2. 使用brew安装软件
比如安装tomcat,在终端输入:brew install tomcat
==> Downloading http://www.apache.org/dyn/closer.cgi?path=tomcat/tomcat-7/v7.0.5
==> Best Mirror http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.53/bin/ap
######################################################################## 100.0%
/usr/local/Cellar/tomcat/7.0.53: 623 files, 14M, built in 4 seconds

可以看到tomcat被安装到了/usr/local/Cellar/目录下。

运行: ls -l bin | grep tomcat,发现bin目录中增加了一个catalina命令,并且指向了tomcat安装目录下的catalina。
lrwxr-xr-x  1 maping  admin      36  5 23 18:25 catalina -> ../Cellar/tomcat/7.0.53/bin/catalina

运行:catalina run,tomcat就启动了。

3. 使用brew卸载软件
运行:brew uninstall tomcat
Uninstalling /usr/local/Cellar/tomcat/7.0.53...

怎么样,使用brew安装和卸载软件很简单吧,你也来试试吧。

参考文献:
1. http://snowolf.iteye.com/blog/774312
2. http://ksmx.me/blog/2013/10/05/homebrew-cask-cli-workflow-to-install-mac-applications/

没有评论: