Archive for 五月, 2011

在linux 中安装 ruby & rails

星期四, 五月 12th, 2011
1. 安装ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
tar xzvf ruby-1.9.2-p180.tar.gz
cd ruby-1.9.2-p180
./configure –prefix=/usr/local/ruby
#prefix选项可以自选
make&&make install
echo “export PATH=/usr/local/ruby/bin:\$PATH” >> /etc/profile
exit
#退出后,让ruby的环境变量其效果
2.安装gem ,用gem来安装ruby需要的各种组件,很强大
wget http://rubyforge.org/frs/download.php/74806/rubygems-1.8.0.tgz
tar xzvf rubygems-1.8.0.tgz
cd rubygems-1.8.0
ruby setup.rb
3.安装rails
gem  install rails
gem install mysql2 -v 0.2.6
mysql2的新版本和rails结合有问题

4.安装apache的rails支持,用passenger

export APXS2=/usr/local/apache/bin/apxs

#此为可选项,如果你的apache是用rpm方式安装的,不用这行语句,如果你的apache安装在别处,后面的参数指向你安装的apache的apxs

passenger-install-apache2-module

根据上条命令的提示,将类似下面的语句放入到httpd.conf中

LoadModule passenger_module /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so

PassengerRoot /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.7

PassengerRuby /usr/local/ruby/bin/ruby

金牌娱乐官方网站虚拟目录,如下

<VirtualHost *:80>

ServerName shallwe.net

ServerAlias www.shallwe.net

DocumentRoot /usr/local/web/shallwe.net/public

RailsEnv development

<Directory /usr/local/web/shallwe.net/public>

Allow from all

Options -MultiViews

</Directory>

ErrorLog “logs/shallwe-error_log”

CustomLog “logs/shallwe-access_log” common

</VirtualHost>