完整linux下配置RMagick步骤 解决RMagick.so cannot open shared object问题
如果你在安装RMagick的时候碰到类似这样的错误:
问题应该是出在共享库的路径上..所以可以尝试在configure之前,先声明路径:
22)added "/usr/local/lib" to /etc/ld.so.conf , then
然后再configure , make ,make install..
送上我在linux上安装RMagick的步骤和经验..这个模块装起来也确实麻烦的很..需要的东西很多..而且路径问题折腾了我好久...闲话不说..下面是步骤
---------------------------------------------------------------------------------------------------
先来安装RMagick 的前提,就是下面这些个模块...
1)安装libjpg
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar -xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --enable-shared
make
make test
make install
2)安装libpng
wget http://easynews.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.16.tar.bz2
tar -xvjf libpng-1.2.16.tar.bz2
./configure
make check
3)安装Freetype
wget http://superb-west.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.2.tar.bz2
tar -xjvf freetype-2.3.2.tar.bz2
cd freetype-2.3.2
make
make
cp objs/.libs/*.so* /usr/local/lib/
cp -rv include/* /usr/local/include/
4)安装Ghostscript
wget http://umn.dl.sourceforge.net/sourceforge/ghostscript/ghostscript-8.54-gpl.tar.bz2
tar xjvf ghostscript-8.54-gpl.tar.bz2
cd ghostscript-8.54-gpl
./configure
make
make install
5)安装Ghostscript fonts
wget http://internap.dl.sourceforge.net/sourceforge/gs-fonts/ghostscript-fonts-std-8.11.tar.gz
tar -xvzf ghostscript-fonts-std-8.11.tar.gz
cp -rv fonts /usr/local/share/ghostscript/
6)安装ImageMagick
wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.3.2-9.tar.bz2
tar -xjvf ImageMagick-6.3.2-9.tar.bz2
cd ImageMagick-6.3.2
./configure --without-perl --without-magick-plus-plus
export PATH=$PATH:/usr/local/ImageMagic/bin
编辑:/etc/ld.so.conf,加入
/usr/local/ImageMagick/lib
执行:ldconfig 查看是否有异常..
确定有以下的配置信息出现:
Ghostscript None gs (8.54)
FreeType --with-freetype=yes yes
JPEG v1 --with-jpeg=yes yes
PNG --with-png=yes yes
接着,make install(run as root)
如果在安装后,系统报字体找不到,把usr/share/fonts/type1字体考到目录/usr/share/ghostscript/fonts/,就可以了。
---------------------------------------------------------------------------------------
至此结束了RMagick的前面步骤...现在就开始了RMagick的安装...比较简单了...你可以选择两种方式:
1. gem安装
gem install rmagick
成功后提示:
Bulk updating Gem source index for: http://gems.rubyforge.org
Building native extensions. This could take a while...
Successfully installed rmagick-X.Y.Z
2. 源码安装:
1) export LD_LIBRARY_PATH=/usr/local/lib
2) added "/usr/local/lib" to /etc/ld.so.conf , then
3) ./configure
4) make && make install
至此RMagick安装结束..
现在来测试下RMagick是否安装成功
irb -rubygems -r RMagick
irb(main):001:0> puts Magick::Long_version 如果输出一下信息则代表OK:
This is RMagick 1.15.3 ($Date: 2007/01/20 15:45:29 $) Copyright (C) 2007 by Timothy P. Hunter
Built with ImageMagick 6.3.2 02/23/07 Q8 http://www.imagemagick.org
Built for ruby 1.8.5 (2006-12-25 patchlevel 12) [powerpc-darwin8.0.0]
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org
=> nil