24 Jul 2010

在centos上装rubyee,passenger和memcached ,搭建rails环境

流水笔记一则.

我之前已在服务器配置了nginx,php,mysql等,现在先安装ruby企业版

cd /tmp
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar -xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
cd ruby-enterprise-1.8.7-2010.02
./installer

然后按照提示做

设置一下环境变量 
export PATH=/rubyee/bin:$PATH
接着
ruby -v
gem -v
看到版本号,说明rubyee 安装ok

下来
gem install passenger
passenger-install-nginx-module

按照提示在nginx配置文件里增加:

http {
     ...
     passenger_root /rubyee/lib/ruby/gems/1.8/gems/passenger-2.2.14;
     passenger_ruby /rubyee/bin/ruby;
     ...
}

  server {
     listen 80;
     server_name www.yourhost.com;
     root /somewhere/public;   # <--- be sure to point to 'public'!
     passenger_enabled on;
  }

rails 欧了~

下来开始装 memcached,

memcached 的使用需要libeven的支持

cd /tmp
wget http://www.monkey.org/~provos/libevent-1.4.14a-stable.tar.gz
tar -zxvf libevent-1.4.14a-stable.tar.gz
cd libevent-1.4.14-stable
./configure --prefix=/usr
make && make install

cd /tmp
wget http://memcached.org/latest
tar -zxvf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure --prefix=/usr/local
make && make install

 现在可以用
service memcached start  


  service memcached stop  

这两个很骚的命令来管理memcached服务了,欧了~

安装mysql gem
gem install --no-rdoc --no-ri mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

安装 ImageMagick

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd ImageMagick*
./configure --disable-static --with-modules --with-gs-font-dir=/usr/share/fonts/type1/gsfonts
make
sudo make install
cd ..
rm -Rf ImageMagick*

wget http://rubyforge.org/frs/download.php/70067/RMagick-2.13.1.tar.bz2
tar -jxf RMagick-2.13.1.tar.bz2
cd RMagick*
./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --with-jpeg=yes --with-png=yes --with-tiff=yes --with-quantum-depth=8  --with-gs-font-dir=/usr/share/fonts/type1/gsfonts
ruby setup.rb
ruby setup.rb install
cd ..
rm -Rf RMagick*

最后 上传 rails 程序
接着 rake gems:install

centos安装rmagick出现以下错误:
libMagickCore.so.2: cannot open shared object file: No such file or directory – /usr/lib/ruby/gems/1.8/gems/rmagick-2.8.0/lib/RMagick2.so
解决办法:

ldconfig /usr/local/lib

错误[memcache-client] Could not load SystemTimer gem, falling back to Ruby's slower/unsafe timeout library: no such file to load -- system_timer
rake aborted!

sudo gem install system_timer

Magick::ImageMagickError (unable to read font `/usr/local/lib/ImageMagick-6.6.3/config//usr/share/fonts/type1/gsfonts/n019003l.pfb' @ error/annotate.c/RenderFreetype/1056: `(null)'):
错误

wget http://sourceforge.net/projects/gs-fonts/files/gs-fonts/8.11%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-8.11.tar.gz/download
 tar -zxvf ghostscript-fonts-std-8.11.tar.gz
解压后拷贝到需要的目录