Skip to content

Instantly share code, notes, and snippets.

@inntran
Created December 18, 2012 05:08
Show Gist options
  • Save inntran/4325226 to your computer and use it in GitHub Desktop.
Save inntran/4325226 to your computer and use it in GitHub Desktop.
Upgrade Ruby on AWS instances. Applied falcon patch. Root required.
#!/bin/bash
export PATH=/usr/local/bin:$PATH
RUBY_VER="1.9.3-p327"
NGINX_VER="1.2.6"
# 1. Create archive of /usr/local
tar --transform='s,usr/local/,,' -cvf /root/ruby_old_pack.tar /usr/local
# 2. Delete contents in /usr/local
rm -rf /usr/local/*
# 3. Install new Ruby
if [ ! -d /root/$RUBY_VER ]; then
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-$RUBY_VER.tar.gz -O /root/ruby-$RUBY_VER.tar.gz
tar -C /root -xf /root/ruby-$RUBY_VER.tar.gz
fi
cd /root/ruby-$RUBY_VER
curl https://raw.github.com/gist/4136373/falcon-gc.diff | patch -p1
autoconf
./configure
make && make install
# 4. Install gems
gem install passenger bundler
# 5. Upgrade passenger path in nginx
sed -i "s/passenger-.*/passenger-`passenger-config --version`;/g" /etc/nginx/nginx.conf
# 6. Compile passenger for nginx
PASSENGER_ROOT=`passenger-config --root`
cd $PASSENGER_ROOT
rake nginx
# 7. Compile nginx with passenger module
cd /root
wget http://nginx.org/download/nginx-$NGINX_VER.tar.gz
tar xf nginx-$NGINX_VER.tar.gz
cd nginx-$NGINX_VER
./configure --prefix=/var/lib/nginx --error-log-path=/var/log/nginx/error.log --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --user=nobody --group=nobody --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --with-http_ssl_module --add-module="$PASSENGER_ROOT"/ext/nginx
make && make install && make upgrade
# 8. Backup new /usr/local contents
cd /root
tar --transform='s,usr/local/,,' -cvf /root/ruby193_dist.tar.gz /usr/local
# 9. Start Server
/usr/sbin/nginx -s reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment