How to Install Latest Ruby on Rails on Ubuntu Linux

After pulling MUCH of my hair (not that I have much left), finally found out the BEST solution from this blog post

  1. Download and install VirtualBox
  2. Download an ISO of Ubuntu 11.04
  3. Create a VM from the Ubuntu ISO
  4. Launch a terminal and prepare Ubuntu for Ruby (instructions adapted from this site)
    1. sudo -i
    2. apt-get update
    3. apt-get -y install build-essential zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev libopenssl-ruby libcurl4-openssl-dev libssl-dev mysql-server
    4. apt-get -y install git-core
    5. apt-get -y install curl wget
  5. Now, build and install Ruby from source (sudo is implied)
    1. cd /usr/local/src
    2. wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
    3. tar -xvf ruby-1.9.2-p180.tar.gz
    4. cd ruby-1.9.2-p180
    5. ./configure
    6. make
    7. make install
  6. Install the gems, including Rails and Passenger, as well as the web server, nginx
    1. gem install rails
    2. gem install passenger
    3. passenger-install-nginx-module
  7. If you receive an OpenSSL error, follow these steps:
    1. cd /usr/local/src/ruby-1.9.2-p0/ext/openssl
    2. ruby extconf.rb
    3. make
    4. make install
  8. Configure nginx to run as a service and to start with the vm (instructions adapted from this site)
    1. adduser –system –no-create-home –disabled-login –disabled-password –group nginx
    2. gedit /etc/init.d/nginx (paste the following code in the file and save it)
    3. #! /bin/sh### BEGIN INIT INFO
      # Provides:          nginx
      # Required-Start:    $all
      # Required-Stop:     $all
      # Default-Start:     2 3 4 5
      # Default-Stop:      0 1 6
      # Short-Description: starts the nginx web server
      # Description:       starts nginx using start-stop-daemon
      ### END INIT INFOPATH=/opt/nginx/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
      DAEMON=/opt/nginx/sbin/nginx
      NAME=nginx
      DESC=nginxtest -x $DAEMON || exit 0# Include nginx defaults if available
      if [ -f /etc/default/nginx ] ; then
      . /etc/default/nginx
      fi
      set -e
      . /lib/lsb/init-functions
      case "$1" in
      start)
      echo -n "Starting $DESC: "
      start-stop-daemon --start --quiet --pidfile /opt/nginx/logs/$NAME.pid \
      --exec $DAEMON -- $DAEMON_OPTS || true
      echo "$NAME."
      ;;
      stop)
      echo -n "Stopping $DESC: "
      start-stop-daemon --stop --quiet --pidfile /opt/nginx/logs/$NAME.pid \
      --exec $DAEMON || true
      echo "$NAME."
      ;;
      restart|force-reload)
      echo -n "Restarting $DESC: "
      start-stop-daemon --stop --quiet --pidfile \
      /opt/nginx/logs/$NAME.pid --exec $DAEMON || true
      sleep 1
      start-stop-daemon --start --quiet --pidfile \
      /opt/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
      echo "$NAME."
      ;;
      reload)
      echo -n "Reloading $DESC configuration: "
      start-stop-daemon --stop --signal HUP --quiet --pidfile /opt/nginx/logs/$NAME.pid \
      --exec $DAEMON || true
      echo "$NAME."
      ;;
      status)
      status_of_proc -p /opt/nginx/logs/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
      ;;
      *)
      N=/etc/init.d/$NAME
      echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
      exit 1
      ;;
      esac
      exit 0

    4. chmod +x /etc/init.d/nginx
    5. /usr/sbin/update-rc.d -f nginx defaults
    6. /etc/init.d/nginx start
  9. Done

In step 6, command “gem” might not be installed correctly.. in that case, do this

1. Download latest ruby gems (.tgz) from here

2. unzip, then run “ruby setup.rb”

3. VOILA

Related posts:

  1. Don’t run PPTP and Squid on mission critical Linux boxes
  2. Installing Imagemagick on WAMPServer vs. Ubuntu
  3. How to setup LAMP stack on Ubuntu VPS
  4. How to set up PPTP VPN on Ubuntu Linux
  5. Texas Real Estate Center’s latest insight on the Economy
Leave a comment

1 Comments.

  1. I’m happy the post was helpful. Sometimes I’m not sure whether or not I should post something, but it seemed like it might be helpful to someone else. Glad to see that was the case here. Good job.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>