I like Ubuntu Server. I really like apt-get, because I don’t have to do any work at all to install stuff. It’s a piece of cake.

Unfortunately, sometimes installing using apt-get doesn’t work, or maybe the software I need isn’t the latest and greatest version on the Ubuntu repository. In such cases, there’s only one option left: installing from source.

That means downloading, extracting, configuring, building, debugging, etc. Most people shy away from doing this because it isn’t fast and easy, and stuff can break.

I recently had the opportunity to install the latest version of ImageMagick on an Ubuntu server, and it was a lot easier than I thought it would be!

Here’s how you do it…

First, keep in mind that almost all software you compile and install has dependencies. Since we’re not using apt-get, you might have to do a little sleuthing and figure out how to install the packages for the necessary dependencies. Fortunately, you can normally just use apt-get for this stuff, and then recompile, and you’re off and running.

Still, this is not a one-size-fits-all solution, and it is not guaranteed to work for you. It really depends on what you have on your system already, what server version you have, etc. So, having said all that, try this:

1. sudo apt-get update

This makes sure we’re gonna get the latest and greatest packages

2. sudo apt-get install build-essential

This ensures you have tools like g++, gcc, make, etc. so you can actually compile ImageMagick

3. sudo apt-get install imagemagick

No, I haven’t lost my mind. This makes sure that you have a whole bunch of dependencies installed without having to manually figure them all out and install them individually. But it still might not give you the latest-and-greatest version of imagemagick, which is why we need to do the install from source!

4. Download the latest version of ImageMagick. You could just do:

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz

5. tar xvfz ImageMagick.tar.gz

Extracts the files

6. cd ImageMagick-6.X.X-X

Change into the directory containing the extracted files

7. ./configure --prefix=/usr

This runs the configure script. With the “prefix” option, you are telling it to install files in /usr instead of the default /usr/local directory. Otherwise, Ubuntu will complain.

NOTE: If you’re getting the Rails error “RMagick was compiled with ImageMagick X.X.X, but Y.Y.Y is installed”, leave off the “–prefix=/usr” part and try again. Then reinstall RMagick. That should do the trick. This is especially annoying on Ubuntu 11.04 and above!

8. make

Build ImageMagick

9. make install

Install ImageMagick

10. identify -version

This should display the proper version of ImageMagick

NOTE: If you get an error like “error while loading shared libraries” when you run the above command, type this:
ldconfig /usr/local/lib

11. identify -list format

This should list the file formats that ImageMagick can process. If anything is missing, you’ll have to install it and recompile

That’s it!

Steps 7, 8, and 9 might take awhile. But now you can install things like RMagick and other toys that use ImageMagick.

If you run into any trouble, Google is your friend. Also, you can read the Advanced ImageMagick Install instructions.

Get Scottie Stuff!