噏 【Up】

Centos5 安装 ImageMagick 6.5 和 Rmagick 2.12,之灵异事件

by Garey on 十一.18, 2009, under Made on a Mac, Projects

之所以说是灵异,是一直以来Centos5上面最新的ImageMagick的源是6.2.8。如果你之前尝试过编译超越这个版本的IM就会知道这是多么的困难,所以我之前也是以6.2.8配合Rmagick1.15.13来运行,虽说有些sample是不能通过但好歹也是跑得动的。

话说上周的某天,Passenger突然报出了

cannot open shared object file: No such file or directory – /usr/lib/ruby/gems/1.8/gems/rmagick-xxx/lib/RMagick2.so (LoadError)

真是汗S了,但问题出现了还是要解决的。开始漫长的debug之路,先安装一次Rmagick吧。。。出错。。。慢着,为什么输出了ImageMagick 6.5.6的提示?赶紧检查。。。哇塞,怎么ImageMagick的版本自己变成6.5.6了?我没有升级的呀。。。。。。。。

不管了,既来之则安之吧。赶紧下载Rmagick2.12.2安装一编。。。通过。。。哈哈哈,真是爽。再打开应用,shit,怎么还是报错?哎,看来都是命苦的了。。。继续debuging。。。一轮的参拜狗狗大神后,终于在Passenger的网站上找到了这一篇文章

http://blog.phusion.nl/2008/12/16/passing-environment-variables-to-ruby-from-phusion-passenger/

其中这段话最重要

But wait, I’ve already set environment variables in my /etc/bashrc or /etc/profile. Why don’t they work?

If you’ve set environment variables in your /etc/bashrc or /etc/profile, then these environment variables are made available in your shell. However, on most operating systems, Apache is not started from the shell and does not load environment variables defined in bashrc/profile, which is why setting environment variables in /etc/bashrc and /etc/profile usually has no effect on Apache (and by induction, on Passenger and Rails processes).

即是说,因为Apache不是以root的身份启动而导致其不能load入部份的配置,所以需要通过配置应用的Enviroment来载入路径,所以如果你也遇到了类似的问题,可以尝试这样做:

1. 停止Apache

2. 执行 export LD_LIBRARY_PATH=/usr/local/lib ,ImageMagick的库安装在这个路径上

3. 去应用的Environment.rb 在 Rails::Initializer.run do |config| … end 之后添加:

ENV['PATH'] = “#{ENV['PATH']}:/usr/local/lib”
ENV['LD_LIBRARY_PATH'] = “#{ENV['LD_LIBRARY_PATH']}:/usr/local/lib”

4. 启动 Apache,然后检查你的应用。

如果有问题的话欢迎留言交流。

:, , ,

1 Comment for this entry

  • Harry Ganske

    Great post. YOu make it seem so easy to share your experiences. I wish I could do as well in sharing on my blog. I just got it started and sometimes feel stuck on what to share or if it is the right thing to share. what to do?

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!