sudo su -Install Ruby and Rails 3:
- The amazon machine instance(AMI) comes with ruby 1.8.7 installed as of today.
- Rails 3 needs ruby 1.9+ to work.
- Ruby 1.9.1 is a buggy version so we will go ahead and install ruby 1.9.2
- We could not find rpms of ruby 1.9.2 on centos repos or even on rpmforge, so we had to go ahead and install ruby from source.
- Download ruby sources from http://www.ruby-lang.org/en/downloads
- wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p136.tar.gz
- unpack it !!
tar xzvf ruby-1.9.2-p136.tar.gz
- Install development tools.
- yum groupinstall ‘Development Tools’
- yum install readline-devel
- Move to ruby sources and compile
- Sit back and relax. Ruby will take some time to compile. It took about 7-9 minutes for us on EC2 micro instance
- After you are done with ruby install. Install rails.
gem install rails
cd ruby-1.9.2-p136 ./configure make && make install
- Install Apache 2.
yum install httpd
yum install httpd-devel
- Install passenger.
- In case you get the following error,
To install OpenSSL support for Ruby:
Please (re)install Ruby with OpenSSL support by downloading it fromhttp://www.ruby-lang.org/. Go to ruby source directory and install openssl extension.
Configure passenger. Depending upon your passenger version you would need to add following lines to your httpd.conf file. (Please note that these directives would come for you after the passenger install, you just need to copy and paste from there). For me the passenger version was 3.0.2:
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/ext/apache2/mod_passenger.so PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.2 PassengerRuby /usr/local/bin/ruby LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.2/ext/apache2/mod_passenger.so PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.2 PassengerRuby /usr/local/bin/ruby
Create virtual host configuration:
<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public # <-- be sure to point to 'public'! <Directory /somewhere/public> AllowOverride all # <-- relax Apache security settings Options -MultiViews # <-- MultiViews must be turned off </Directory> </VirtualHost>
yum install postgres
Thats it !! We are all done with our awesome rails 3 stack on Amazon EC2 !!
Please feel free to post any queries in the comments.