You need to install the following packages before you can build the Paperclip gem:
sudo apt-get install imagemagick librmagick-ruby