While you can download Ruby directly from here or from repositories (though you may not find latest version in it). I preferred using the awesome Ruby version manager tool (rvm) for this purpose. Our setup was in requirement of latest Ruby, Gems and Passenger with Apache2 module and that setup seems to be straightforward but I faced lots of smaller issues and hence thought of collecting and putting final commands here so that next time it would be a quick setup without all that digging.
These commands are tested successfully in Ubuntu 12.04 ec2 instance.
Step 1. Install essential packages
I am using latest Ubuntu 12.04 AMI in a new small instance. We need to install required packages/libraries first otherwise you will be bumped up with hiccups and needs to install them one by one when got stuck so let’s install them at first place itself:
$ sudo apt-get install build-essential apache2 zlib1g-dev libcurl4-openssl-dev libssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
Step 2. Install RVM and latest stable Ruby
We will install RVM and specify that it should install latest stable Ruby as well.
$ sudo curl -L https://get.rvm.io | sudo bash -s stable --ruby $ source /usr/local/rvm/scripts/rvm
Please note that you need to run the last ‘source /usr/local/rvm/scripts/rvm’ command once for all users where Ruby availability is needed otherwise other users won’t find Ruby like below example:
$ su exampleuser $ ruby --version The program 'ruby' can be found in the following packages: * ruby1.8 * ruby1.9.1 Try: sudo apt-get install <selected package> $ source /usr/local/rvm/scripts/rvm $ ruby --version ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Ruby is installed. Let’s proceed to setup Apache2 with Passenger now.
Step3. Install Passenger and its apache module
We need to install OpenSSL extension/library for Ruby, I tried installing it with apt-get but that’s also fetching Ruby1.8 libraries which I don’t want to install, so I got it from Ruby source code, compiled and installed:
$ cd /usr/local/rvm/src/ruby-1.9.3-p194/ext/openssl/ $ sudo ruby extconf.rb $ sudo make && sudo make install
Time to install passenger, module for apache and configure apache to use that module:
$ sudo gem install passenger $ sudo passenger-install-apache2-module $ sudo vim /etc/apache2/httpd.conf LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17 PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby $ sudo service apache2 restart
Setup is done.
If you enjoyed this article, please share it with your friends. If there’s any issue/correction/suggestion, I’d be glad to hear that, please put it in comments below.
Other helpful articles in this blow on AWS ec2:
- Quickly setup git server with gitolite, gitweb, ssh and http auth
- Create secure mongodb replica-set in aws ec2 instance
- create and manage raid0, raid10 using ebs volumes in aws ec2 instance
- Simple upstart job in ubuntu to ensure your processes keep running
- Install and configure ftp server in aws ec2