Monday, March 3, 2014

How to installing Ruby on Rails on Centos 5

In this case i'm using RVM for installing ROR, now let's begin
Update your packages:
sudo yum update

1. Install RVM

sudo yum install curl
curl -L get.rvm.io | bash -s stable
After installed RVM, close your terminal and login back to use the "rvm" command:
RVM has some dependencies to need install, run this command.
rvm requirements
and install some recommended dependencies:
rvmsudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
rvm list known
Will display like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1.1
[ruby-]2.1-head
ruby-head
Install the Ruby
rvm install 2.1.1
rvm use 2.1.1 --default
check the version installed Ruby and Gem
ruby -v
gem -v

2. Install Rails

gem install rails

3. Install mysql gem

First, install the mysql dev:
sudo yum install mysql-devel
gem install mysql2

3. Install Phusion Passenger

gem install passenger
yum install curl-devel httpd-devel 
passenger-install-apache2-module
Put these lines to end of file in httpd.conf, edit the file at /etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
   < IfModule mod_passenger.c >
     PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.37
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
   < /IfModule >
Adding new virtual host:
vi /etc/httpd/conf.d/your_vhost_name.conf
Add these line, set up your public app directory:
< VirtualHost *:80 >
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public    
      < Directory /somewhere/public >
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      < /Directory >
   < /VirtualHost >
Restart your apache
service httpd restart

No comments:

Post a Comment