In this example, we are going to deploy the BoxRoom Rails application. BoxRoom is a simple application whose sole purpose is to allow users to store and retrieve arbitrary files. This example is a little more difficult than the previous example because BoxRoom requires an earlier version of Rails as well as the need to install native Ruby Gems.
Steps Involved
-
Log in to your JumpBox
All of the following shell commands will be executed directly on the JumpBox for Ruby on Rails. If you've already gone through the process of configuring and registering your JumpBox, then you're ready to begin. Use SSH to login to your JumpBox. The IP address is displayed on the JumpBox's console screen, the user name will be 'admin', and your password is what you set during the initial JumpBox setup.
Once you're logged in, you can begin deploying your first Rails application by typing the following commands at the bash prompt. Note that you don't have to type the commented lines (they begin with a #).
# Stop the Apache Webserver sudo /etc/init.d/apache2 stop
-
Install Rails 1.2.6 on the JumpBox
By default, the JumpBox for Ruby on Rails only ships with version 2.3.2 of Ruby On Rails. BoxRoom requires Ruby on Rails version 1.2.6 as well as the Ferret and acts_as_ferret Gems. That said, we will need to install these packages on our JumpBox.
All of this can be accomplished by logging into your JumpBox via SSH and issuing the following commands:
# Install Ubuntu's Build-Essential toolchain sudo apt-get update; sudo apt-get install build-essential ruby1.8-dev # Install Ruby On Rails version 1.2.6 sudo gem install --no-rdoc --no-ri -v=1.2.6 rails # Install Ferret and acts_as_ferret sudo gem install --no-rdoc --no-ri ferret acts_as_ferret
You may optionally remove Rails 2.1.0.
# Remove Ruby On Rails version 2.1.0 and its dependencies sudo gem uninstall -v=2.1.0 actionmailer actionpack activerecord activeresource activesupport rails
-
Download and Install BoxRoom
BoxRoom is available at boxroom.rubyforge.org and can be downloaded by clicking on the "BoxRoom v0.6.2" link on the left side of the page under "Latest releases". Our example will download it using 'wget' to spare you the trouble.
# Move the Skeletal Rails application out of the way mv /var/data/app/current /var/data/app/orig # Retrieve BoxRoom version 0.6.2 wget http://rubyforge.org/frs/download.php/17642/boxroom.0.6.2.zip -P /var/data/app/ # Unzip BoxRoom unzip /var/data/app/boxroom.0.6.2.zip -d /var/data/app # Remove the ZIP file rm /var/data/app/boxroom.0.6.2.zip # Rename the BoxRoom directory to current mv /var/data/app/boxroom /var/data/app/current # Recursively change ownership of current so that it uses the www-data group sudo chown -R admin:www-data /var/data/app/current
-
Install the BoxRoom Database
By default, BoxRoom points to a non-existent MySQL database. We'd like it to use the database that the JumpBox for Ruby on Rails ships with, so we'll simply copy the database.yml configuration file from our original skeletal Rails app to the BoxRoom configuration directory, followed by performing the standard Rails migration task.
# Copy the JumpBox's default database over BoxRoom's cp /var/data/app/orig/config/database.yml /var/data/app/current/config/database.yml # Change to the root of the Rails apps directory cd /var/data/app/current # Set your Rails environment to production export RAILS_ENV=production # Create the Rails database (uses RAILS_ENV) rake db:migrate
-
Restart the Apache Webserver
The Apache Webserver running on the JumpBox needs to be started once again so that you may access your newly deployed Rails application.
# Restart the Apache Webserver and Passenger sudo /etc/init.d/apache2 start
That's it! BoxRoom should now be running on your JumpBox. You can confirm this by pointing your browser to the standard http endpoint of the JumpBox.