Unattended Passenger / Ruby Enterprise Installation on Ubuntu 8
Dec.17, 2008 in
Ruby
[update @ 15-03-09]
Updated the script to use the latest passenger 2.1.2 and the lastest version of Ruby Enterprise. Also made a few changes as suggested in the comments, thanks guys!
I needed a small project that I could use to learn some basic bash scripting. Since I like automating things a unattended passenger installation seemed like a cool thing. It’s far from perfect but it gets the job done. (on Ubuntu 8.04/8.10 at least).
Feel free to post any improvements you may have.
#!/bin/bash #!/bin/bash # Unattended REE/Passenger installation # Source: http://weblog.brightlight-ict.nl/2008/12/unattended-passenger-ruby-enterprise-installation-on-ubuntu-8/ if [ "$(whoami)" != "root" ]; then echo "You need to be root to run this!" exit 2 fi VERSION="1.2" REEV="http://rubyforge.org/frs/download.php/51100/ruby-enterprise-1.8.6-20090201.tar.gz" REEF="ruby-enterprise-1.8.6-20090201.tar.gz" REEFF=${REEF%".tar.gz"} PASSENGER="2.1.2" export PASSENGER echo "#####################################" echo "Welcome, let's get this party rollin'" echo "#####################################" echo "Updating Aptitude" apt-get update echo "Installing build essentials" apt-get install build-essential zlib1g-dev libssl-dev wget libreadline5-dev -y echo "Installing GIT" apt-get install -y git-core echo "Installing apache" apt-get install -y apache2 echo "Installing apache headers" apt-get install -y apache2-prefork-dev echo "Installing Ruby Enterprise from following url" echo $REEV wget $REEV if [ -e $REEF ] then echo "File downloaded succesful" else echo "Error, file wasn't downloaded!" exit fi tar -zxvf $REEF # possible options perhaps for checker # --extra rails --no-tcmalloc if [ -d ./$REEFF ] then ./$REEFF/installer --auto /opt/ruby echo "Dir test" else echo "Dir not found, exiting.." exit fi echo "Creating ruby symlinks" ln -s /opt/ruby/bin/ruby /usr/bin/ruby ln -s /opt/ruby/bin/gem /usr/bin/gem ln -s /opt/ruby/bin/rake /usr/bin/rake ln -s /opt/ruby/bin/rails /usr/bin/rails echo "Installing other gems" gem install rails gem install will_paginate gem install shoulda gem install mysql echo "Installing passenger" gem install passenger -v=$PASSENGER echo "Config passenger" yes '' | /opt/ruby/bin/passenger-install-apache2-module echo "Copying passenger files" touch /etc/apache2/mods-available/passenger.load touch /etc/apache2/mods-available/passenger.conf echo "LoadModule passenger_module /opt/ruby/lib/ruby/gems/1.8/gems/passenger-$PASSENGER/ext/apache2/mod_passenger.so" >> /etc/apache2/mods-available/passenger.load echo "PassengerRoot /opt/ruby/lib/ruby/gems/1.8/gems/passenger-$PASSENGER PassengerRuby /opt/ruby/bin/ruby" >> /etc/apache2/mods-available/passenger.conf echo "Enabling passenger module" a2enmod passenger echo "Reloading apache" /etc/init.d/apache2 reload echo "##########################" echo "# Installation Complete" echo "##########################" sleep 2 echo "##########################" echo "# Installed Ruby Version #" echo "##########################" ruby -v echo "##########################" echo "# Installed Gems Version #" echo "##########################" gem -v /opt/ruby/bin/passenger-status
You can find the gist here

December 22nd, 2008 at 7:53 pm
would it not be worthwhile checking $? for a return value and aborting if there is an error somewhere along the way?
December 22nd, 2008 at 11:19 pm
Very kind of you to post your bash script. This will be useful for a lot of people, I’m sure!
thanks!
December 23rd, 2008 at 12:02 am
@Tim
You are probably right yeah that could be a good improvement. But remember this is my first attempt at anything bash-like so I went for something really basic first. I’ll try to “upgrade” the script and see if I can add some more error checking!
December 23rd, 2008 at 1:40 am
Wouldn’t it be better to use aptitude instead of apt-get?
December 23rd, 2008 at 3:15 am
@Arthur
“Aptitude is a curses (terminal-based) front-end for apt.”. Reading is I can’t really see that it would such a big difference. You got any reasons for using aptitude of apt-get?
December 23rd, 2008 at 5:45 am
Thanks for posting this! The more resources out there for Ruby web developers the better.
A few comments:
You could remove the sudo before each command and throw a check at the top to see whether the script is being run as root, something like:
Then you’d just have to call the script with sudo.
Brightbox actually run an ubuntu-ruby-backports repo that does all the heavy lifting for you Passenger-wise (though they don’t yet package REE).
You can find more info on how to add their repo to your system at https://launchpad.net/~ubuntu-ruby-backports/+archive
If you’re looking at extending your automation further, you might want to consider using something like Puppet:
http://puppet.reductivelabs.com/
It lets you describe your setup in high level terms that can easily be applied to different versions of Linux/Unix.
I wrote about my personal experiences with configuring systems with scripts on my blog here:
http://holmwood.id.au/~lindsay/2008/11/04/why-scripting-your-server-install-is-a-bad-idea/
I’m going to put together some sysadmin screencasts sometime early in the new year which will serve as an introduction to sysadmin for Ruby web developers.
December 23rd, 2008 at 10:37 am
See http://pthree.org/2007/08/12/aptitude-vs-apt-get/ for a comparison of apt-get and aptitude.
December 23rd, 2008 at 9:44 pm
[...] Unattended Passenger / Ruby Enterprise Installation on Ubuntu 8 [...]
December 25th, 2008 at 2:21 am
A script like this should absolutely use apt-get, not aptitude. apt-get is part of the base system. aptitude isn’t.
January 8th, 2009 at 6:10 pm
Great server setup script!
I wrote a couple similar ones (http://blog.fiveruns.com/search?q=slicehost) using mongrel, Thin and nginx, but I like your Passenger choice, especially passing the yes argument to keep it automatic.
Thanks for publishing this.
Mark
December 14th, 2009 at 6:24 am
You not going to believe this but I have wasted all day researching for some info about this. I wish I knew of this site earlier, it was a fantastic read and really helped me out. Kind regards,Dynalite