macports(darwinports)是mac操作系统上的一个非常不错的包管理器,可以很方便的编译安装软件,在安装一个软件的时候会将这个软件所依赖的软件环境一起搭建好,这样可以很方便的安装和升级所需要的软件。就像gem一样的方便。


http://www.macports.org/install.php
这是macports的安装说明
http://guide.macports.org/
这是macprots的完整的说明书

用macports*.dmg来安装macports,位于/opt目录下。如果对于port卸载命令卸载软件失败时,可以直接将opt文件夹删除

一般情况使用macports*.dmg安装之后,环境变量中会包含/opt/local/bin如果没有添加到~/.bashrc里即可。
重启terminal,运行
sudo port selfupdate

更新ports tree和macports版本

----下面是用macports来安装ror环境来说明macports的好用之处:

以前对于ruby的安装是比较麻烦的,需要gnu的readline(比较容易出现很多问题,譬如ldconfig 问题)
现在用macports可以很方便的来安装ruby:

---> Computing dependencies for ruby
---> Fetching gperf
---> Attempting to fetch gperf-3.0.4.tar.gz from ftp://ftp.dti.ad.jp/pub/GNU/gperf
---> Verifying checksum(s) for gperf
---> Extracting gperf
---> Configuring gperf
---> Building gperf
---> Staging gperf into destroot
---> Installing gperf @3.0.4_0
---> Activating gperf @3.0.4_0
---> Cleaning gperf
---> Fetching libiconv
---> Attempting to fetch libiconv-1.13.tar.gz from ftp://ftp.dti.ad.jp/pub/GNU/libiconv
---> Verifying checksum(s) for libiconv
---> Extracting libiconv
---> Applying patches to libiconv
---> Configuring libiconv
---> Building libiconv
---> Staging libiconv into destroot
---> Installing libiconv @1.13_0
---> Activating libiconv @1.13_0
---> Cleaning libiconv
---> Fetching ncursesw
---> Attempting to fetch ncurses-5.7.tar.gz from ftp://ftp.dti.ad.jp/pub/GNU/ncurses
---> Verifying checksum(s) for ncursesw
---> Extracting ncursesw
---> Configuring ncursesw
---> Building ncursesw
---> Staging ncursesw into destroot
---> Installing ncursesw @5.7_0
---> Activating ncursesw @5.7_0
---> Cleaning ncursesw
---> Fetching ncurses
---> Verifying checksum(s) for ncurses
---> Extracting ncurses
---> Configuring ncurses
---> Building ncurses
---> Staging ncurses into destroot
---> Installing ncurses @5.7_0
---> Activating ncurses @5.7_0
---> Cleaning ncurses
---> Fetching zlib
---> Attempting to fetch zlib-1.2.3.tar.bz2 from http://distfiles.macports.org/zlib
---> Verifying checksum(s) for zlib
---> Extracting zlib
---> Applying patches to zlib
---> Configuring zlib
---> Building zlib
---> Staging zlib into destroot
---> Installing zlib @1.2.3_3
---> Activating zlib @1.2.3_3
---> Cleaning zlib
---> Fetching openssl
---> Attempting to fetch openssl-0.9.8k.tar.gz from http://distfiles.macports.org/openssl
---> Verifying checksum(s) for openssl
---> Extracting openssl
---> Applying patches to openssl
---> Configuring openssl
---> Building openssl
---> Staging openssl into destroot
---> Installing openssl @0.9.8k_0+darwin
---> Activating openssl @0.9.8k_0+darwin
---> Cleaning openssl
---> Fetching readline
---> Attempting to fetch readline-6.0.tar.gz from ftp://ftp.dti.ad.jp/pub/GNU/readline
---> Verifying checksum(s) for readline
---> Extracting readline
---> Applying patches to readline
---> Configuring readline
---> Building readline
---> Staging readline into destroot
---> Installing readline @6.0.000_2+darwin
---> Activating readline @6.0.000_2+darwin
---> Cleaning readline
---> Fetching ruby
---> Attempting to fetch ruby-1.8.7-p174.tar.bz2 from ftp://ftp.ruby-lang.org/pub/ruby/1.8
---> Verifying checksum(s) for ruby
---> Extracting ruby
---> Applying patches to ruby
---> Configuring ruby
---> Building ruby
---> Staging ruby into destroot
---> Installing ruby @1.8.7-p174_0+darwin+thread_hooks
---> Activating ruby @1.8.7-p174_0+darwin+thread_hooks
---> Cleaning ruby


这样安装就可以将ruby及其所依赖的软件环境全部搭建好了,现在可以运行一下
port installed
来查看用port安装过的包及其版本号:

port installed
The following ports are currently installed:
gperf @3.0.4_0 (active)
libiconv @1.13_0 (active)
ncurses @5.7_0 (active)
ncursesw @5.7_0 (active)
openssl @0.9.8k_0+darwin (active)
readline @6.0.000_2+darwin (active)
ruby @1.8.7-p174_0+darwin+thread_hooks (active)
zlib @1.2.3_3 (active)



再下面来安装mysql: