Since getting my MacBook pro in early 2009 MacPorts has been one of the best and most useful tools I have discovered for it. MacPorts is a package management system similar to Debian’s apt-get. It allows you to install any of the 1000’s of packages that are available on other Unix platforms.  To use it, you’ll need Xcode which is Apple’s free integrated development environment.  Make sure you include both X11SDK and Unix Development when you grab the Xcode package.  Xcode is a huge package but it’s worth the space for ports and because it comes with Dashcode which is a nice little text editor that properly saves html, php, etc unlike text edit.

Once you have Xcode downloaded and installed, then grab the pre-built dmg file for your version of OS X from here.  One of the first commands you’ll want to make a note of is the update command.  That brings MacPorts itself up to date.  To run it you type:

sudo port -v selfupdate

More important is the package update command.  This one could take a while to run depending how many packages you have installed since it will download and recompile any outdated packages and dependencies you may have installed.  Be forwarded my computer took over an hour to upgrade.  To run it you type:

sudo port upgrade outdated

At the time of this blog post there are 6818 ports currently available.  You can see all of the ports right here.  The ports are categorized and searchable.  You can also search through all of the available ports right on the command line with these two commands:

ports list

ports search package

Once you find a package you want, installing it is a snap.  You just type:

sudo port install package

After you have installed a few ports, you can see a list of all ports and all dependencies that you currently have installed by typing:

port installed

Every time I look at the list I see new packages to install.  A few of my favorites are Perl, mysql, nmap & lynx.  You might laugh at Lynx but it really can be handy in a pinch.  Especially if you are SSH’ing into your Mac remotely.  Even if your package is not available, ports is really the best way to install dependencies for other packages that you may need to compile.  Things like gmake, autoconf & automake can be critical to running ./configure scripts and ports will make dependency hell a little less painful.

One final caveat is that when you upgrade to the next version of OS X, it will probably break some/most/all of your ports.  I haven’t had this experience yet but I’m guessing it won’t be much more painful than possibly upgrading Xcode, the MacPorts binary and running the upgrade command again.

If you like the content on this site, please support it by using this link to order from Amazon. You know you were going to go there and buy stuff anyhow so why not help me pay the hosting bill.