Home > Apple Mac, Ruby on Rails > How to get Phusion Passenger and ImageMagick to work together?

How to get Phusion Passenger and ImageMagick to work together?

July 5th, 2008

For Studio Gallery, I want people to have the ability to upload avatars for the clients that they create. I am using the Paperclip plug-in for this and when running the app via script/server this works great. I installed ImageMagick and Paperclip is able to find it since all the right paths are set in my .bash_profile file.

The problem is that I can’t get Paperclip or ImageMagick to work when running the app via Passenger. I have added the following lines to my /etc/profile file:

#ImageMagick
export MAGICK_HOME="/usr/local/ImageMagick-6.4.1"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib"
export PATH=$MAGICK_HOME/bin:/usr/bin:$PATH

But so far, it seems that Apache or Passenger is unable to find ImageMagick. Anyone have any ideas?

Categories: Apple Mac, Ruby on Rails Tags:
  1. July 5th, 2008 at 07:41 | #1

    If you’re running passenger/apache with a specific user account, have you verified it has the proper access to /usr/local/ImageMagick and /tmp (since it create temporary files over there).

    Just a suggestion, since similar stuff happened to me running PaperClip.

    HTH.

  2. July 5th, 2008 at 08:45 | #2

    The problem is that Passenger is not setting environment variables when launching Ruby processes.

    You can use my workaround to set necessary environment variables when using Passenger.

  3. July 5th, 2008 at 08:59 | #3

    The problem is that Passenger is not setting environment variables (that you set in /etc/profile) for launched Ruby processes.

    You can use my workaround to set necessary environment variables when using Passenger mod_rails.

  4. August 7th, 2008 at 10:57 | #4

    I have write post (Spanish) for this issue in my blog

  5. August 8th, 2008 at 20:55 | #5

    Cool, now if I only spoke Spanish ;-)

  6. August 25th, 2008 at 13:09 | #6

    I was having this same problem with phusion passenger (mod_rails) and the paperclip plugin with ImageMagick. I tried the various solutions found on the web involving changing environment variables, but to no avail.

    I originally installed ImageScience via source on slicehost. Then after uninstalling that by doing sudo make uninstall, I reinstalled by doing:

    sudo aptitude install imagemagick librmagick-ruby1.8 librmagick-ruby-doc libfreetype6-dev xml-core -y

    Then I restarted the server and it worked. Craziness.

  7. Matt
    September 7th, 2008 at 00:16 | #7

    Were you able to solve this? There is a thread in the passenger google group.
    http://tinyurl.com/66emex

    if RAILS_ENV == “development”
    Paperclip.options[:image_magick_path] = ‘/usr/local/’
    end

    in an initializer was their solution. I haven’t gotten this to work.

    mp

  8. December 28th, 2008 at 04:49 | #8

    Putting this in an config/initializers/paperclip.rb file in OSX fixed the problem for me:

    if RAILS_ENV == “development”
    Paperclip.options[:image_magick_path] = ‘/opt/local/bin’
    end

  9. Mat
    February 15th, 2009 at 10:45 | #9

    I didn’t want to install ports or hack Ruby, here’s a patch we submitted to paperclip that allows you to use Paperclip Phusion ImageMagick nicely: http://thoughtbot.lighthouseapp.com/projects/8794-paperclip/tickets/109-phusion-passenger-mod_rails-issue-on-osx

Comments are closed.