back | parent

Howto Install Homebrew.

If you're currently running Mac 0S X and are looking to get into the more technical "geekier" side of things, you might be interested in knowing about Homebrew. It's a great introduction to some really spectacular UNIX software.

Installing a Compiler

In order for code to run, it must be converted from source code to binary code that is compatible with whatever CPU it is being run on. This process is called "compiling" or "building" and it is done with a Compiler. Apple does not feel it is important for you to be able to compile and so they do not ship with a compiler, but you can download one and install it from

Without this, Homebrew will be useless, so go install the compiler now.

Installing XQuartz

The fact that some UNIX applications run in their own window (ie, not just as text within the Terminal) can be attributed to something called a "graphic server". The de facto graphic server in the UNIX world as of this writing is X, also known as Xorg or X11. The X11 application that Apple ships is OK in a pinch but it's not often updated and is usually already out of date even when it ships directly from Apple on a new 0S X release disc. You should download the version that is maintained by the larger community from and install it.

Installing Homebrew

Homebrew is a Ruby application, so just open up a Terminal and type in this simple command to install:

curl -fsSL -o homebrew.rb

Open up the homebrew.rb file in a text editor like gedit or emacs and review the code. You don't really need to know Ruby to get a feel for what it's doing (in other words, make sure you're not downloading malicious code) and then install:

ruby ./homebrew.rb

That's it. You're done. You've successfully installed Homebrew and you even reviewed the code before blindly installing it. Why? because only n00bs copy-paste code without looking before they leap - and my friend, we are not n00bs. OK, yeah we are. Anyway, read on for a little bit of instruction on how to actually use this here fancy homebrew thing.

Using Homebrew

So what is homebrew anyway? Well, in the UNIX world (of which you are now dangerously close to becoming a part), applications are usually installed by something we call a package manager. There are lots of different ones out there, and homebrew is just another one of them.

A package manager is many things, but mostly it:

It might take you a little time to get over the idea of how you used to find cool new applications; you'd go out to the web, browse some sites, download a .dmg or .pkg or .mpkg or [hidden suffix] .app file and double-click it to install, or drag it into /Applications so you can run it. You can still do all of that, but instead of downloading a file and installing, you should open a terminal and fire up homebrew and let it do your downloading and installing (when an application you want is available through homebrew, that is).

  1. So let's see what's available through homebrew.

    $ brew search

    That command does a search for nothing, or, said another way, everything. This will be overwhelming, so you can redirect the results into a file and then browse the file in gedit or emacs or the built-in terminal viewer called more.

    $ brew search > brew.list
    $ more brew.list

    Press the RETURN key to scroll through the list.

    Some of the applications might sound familiar to you, others may be foreign. Some package managers provide little blurbs about what each application does; homebrew does not [at least at the time of this writing], so the internet is your friend; do a search on unfamiliar application names to find out what they do.

  2. Let's say you have browsed the available packages and decide you want to install the lightweight web server, nginx:

    $ brew install nginx

    Homebrew will download the source code for nginx plus any smaller application that it needs to run properly (pcre specifically, but for some other application it would be somne other dependency; the point is that homebrew manages those for you, too), compiles it, and installs it on your system.

  3. Now that nginx is installed, you would want to configure and run it. You know how on Mac 0S, after you install something there are those after-installation steps? like ejecting the disk image, or throwing the .dmg in the trash or archiving it some place so you can re-instal easily later, or however you manage your system? Well, on UNIX the package manager archives and tracks everything for you, so there's no cleanup to do, so the typical steps after installing something for me are to:

    1. Read the documentation, usually with man
    2. Edit the configuration file; homebrew wisely avoids messing around in Apples's version of /etc, so all of the config files should appear in /opt/etc or thereabouts
    3. Start the application

    Go through those steps for everything you install, and you should find that everything works more or less as expected. There might still be some Mac-isms that you have to hack around; in fact, the logistics of running nginx on Mac 0S X, on port 80, I have to leave up to you because I've never done that. But an application like wget will run without any hacks at all. So it just depends on what you are trying to do.

And now you have a good idea of how to use homebrew to get a bunch of high-tech free applications, so explore!

Remember that homebrew is a hack; Apple doesn't do anything to support what you are doing and in fact sometimes they do things to make it seem like they're seriously trying to stop you from using these applications. Either way, many of the UNIX applications will need a few hacks in the way you run them. In every case, you should probably check the project's website first to see if they don't have an official Mac release. Don't go installing GIMP or gedit, for example, when there are native-Mac builds available from their websites. They still aren't completely integrated, but it's better than running within Apple's version of X11.

If you start getting really invested in the applications you find via homebrew, then you may want to pick up a spare computer and give Linux or BSD a try, because the applications will run much smoother (in the sense that you don't have to hack around the environment in order to install, start, and maintain them, and that they will be integrated with the rest of your system in every way and not hacked into it via a secondary graphics server). I value my early experience running UNIX applications on Mac 0S X because I did learn a lot, but eventually it might become time to put away your childish things and become a real UNIX man/woman/alien. Have fun!