Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Installation Instructions

drkraven edited this page Aug 12, 2014 · 18 revisions

The installation will require the installation of the following components

  1. Ubuntu (these instructions are for Ubuntu version 12.04 LTS)

  2. Configure Proxy Settings

  3. Git

  4. RVM and Ruby 2

  5. MongoDB

  6. Libxml2

  7. Nokogiri

  8. Bonnie Source Code

  9. Configure Startup Processes

  10. Configure Passenger / Apache

  11. Installing Ubuntu


The ISO for ubuntu 12.04 LTS can be downloaded from the following URL: http://releases.ubuntu.com/precise/

These instructions were developed against the "64-bit PC (AMD64) server install CD" (ubuntu-12.04.1-server-amd64.iso).

Installing Ubuntu is a fairly straight-forward process, but for more details on installing Ubuntu please visit the following URLs:

Graphical install using the desktop CD: https://help.ubuntu.com/community/GraphicalInstall

Installation using the Alternate CD (more configuration options): https://help.ubuntu.com/12.04/installation-guide/index.html

Once Ubuntu has been installed you need to update the Apt packages.  Apt is a software package management system used by Ubuntu. Note: the last command in the group below is only necessary if any packages were actually upgraded.

sudo apt-get update
sudo apt-get upgrade
sudo shutdown -r now

Once the machine reboots you will likely want to install an SSH server.  This will allow you to connect remotely to the machine.

sudo apt-get install openssh-server

Once SSH is installed, you can determine the IP address of the machine using the command

ifconfig

In the output of this command, look under the block labelled eth0, you should find an IP address after the label inet addr:.

  1. Configure Proxy Settings

This step is only required if the server you are installing Bonnie onto needs to go through an HTTP proxy server to reach the internet. These steps will ensure that the appropriate proxy settings are in place for every user that logs into the system.

Use your favourite text editor to create a file in /etc/profile.d named http_proxy.sh with the following contents. In the sample below, replace your.proxy.host.com with the fully-qualified host name of your proxy server, and your.proxy.port with the port number that the proxy server uses.

# Set up system-wide HTTP proxy settings for all users
http_proxy='http://your.proxy.host.com:your.proxy.port/'
https_proxy='http://your.proxy.host.com:your.proxy.port/'
export http_proxy https_proxy

Set proper permissions on the new file, and load the settings into the current environment. NOTE: the proxy settings will automatically be loaded when a user logs in, but we are manually loading them here, to avoid having to log out and log back in again.

sudo chmod 0644 /etc/profile.d/http_proxy.sh
source /etc/profile.d/http_proxy.sh

Make sure that the sudo command will allow the new proxy settings to be passed to commands it launches. This is done by using your text editor to create a file in the /etc/sudoers.d directory named http_proxy (no extension) with the following contents:

# keep http_proxy environment variables.
Defaults env_keep += "http_proxy https_proxy"

Set proper permissions on the new file:

sudo chmod 0440 /etc/sudoers.d/http_proxy
  1. Installing Git

Git is a source control system.  It will be used later to download the Bonnie source code.

sudo apt-get install git-core
  1. Installing RVM and Ruby 2.0

RVM is a system that allows managing different versions of Ruby.  It will allow the correct version of ruby to be easily installed on the system. Ruby is the development language used for the Bonnie application.

First we will need to install some dependencies:

sudo apt-get install build-essential openssl libssl-dev libreadline6 libreadline6-dev curl zlib1g zlib1g-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

Next install RVM.  This will install RVM for all users

curl -L get.rvm.io | sudo -i bash -s stable

Log out, and then log back in again so that the settings RVM installs will be loaded in your environment. Once you have logged back in, run the following commands. These will install some more dependencies.

We will install these dependencies using an admin console. The admin console can be opened with the following command:

sudo -i

Next we want to set the autolibs flag in rvm

rvm autolibs enable

Next we want to install Ruby 2.0.0 using RVM

rvm install 2.0.0

If you get a message about installing dependencies, press 'q'.  We have already installed everything we will need.

Set ruby version 1.9.3 to be the default version:

rvm --default 2.0.0

Install bundler.  Bundler is a Ruby Gem that allows downloading additional dependencies once we have the Bonnie source code:

gem install bundler

Close the admin console by running:

exit

setup rvm for the admin user:

source /etc/profile.d/rvm.sh
rvm use 2.0.0
rvm --default 2.0.0
  1. Installing MongoDB

MongoDB is the database used by Bonnie.  To install MongoDB run the commands:

sudo sh -c "echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' >> /etc/apt/sources.list"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
sudo apt-get update
sudo apt-get install mongodb-10gen=2.4.6

To test connection (wait at least 15 seconds to let the db start up), run the command below. If the command exits with a error about not being able to connect, then reboot, and log back in as the admin user. Sometimes mongodb fails to create a network socket when it is started immediately after installation. It should automatically start when the system is rebooted.

mongo

This should output MongoDB shell version: 2.4.x

Type 'exit' to exit the mongo shell

exit
  1. Installing libxml2 2.8 from source

Libxml2 version 2.8 must be installed for XML processing and validation.  It can be installed from source using the following commands:

cd /tmp
wget ftp://xmlsoft.org/libxml2/libxml2-2.8.0.tar.gz
tar xzf libxml2-2.8.0.tar.gz
cd libxml2-2.8.0/
./configure 
make
sudo make install
cd
  1. Installing Nokogiri using libxml2 2.8

Nokogiri is used by Bonnie for XML processing and validation and must be installed against the libxml2 2.8 libraries that were installed in step 6.

sudo -i
gem install nokogiri -v '1.6.0' -- --with-xml2-dir=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2
exit
  1. Bonnie Source Code

add bonnie user

sudo adduser bonnie
sudo usermod -G sudo bonnie
sudo su - bonnie

Getting the Bonnie code

git clone https://github.com/projecttacoma/bonnie.git
cd bonnie
bundle install
bundle exec rake assets:precompile 
exit
  1. Configure Passenger / Apache

Install apache and passenger with the following commands:

sudo -i
apt-get install apache2
gem install passenger

These should be the dependencies required for passenger:

apt-get install libcurl4-openssl-dev apache2-prefork-dev libapr1-dev libaprutil1-dev

Install the apache passenger module.  If you need other dependencies, the installer will tell you:

passenger-install-apache2-module

Add a file (as root, using sudo -i):

/etc/apache2/sites-available/bonnie

With the following content (changing the path appropriately):

 <VirtualHost *:80> 
  DocumentRoot <path>/bonnie/current/public 
  <Location /assets/> 
# Use of ETag is discouraged when Last-Modified is present
Header unset ETag
FileETag None 
# RFC says only cache for 1 year
ExpiresActive On 
ExpiresDefault "access plus 1 year"
  </Location>
  <Directory <path>/bonnie/current/public> 
AllowOverride all
Options -MultiViews
# Compress css and js
AddOutputFilterByType DEFLATE text/css application/x-javascript application/javascript text/javascript 
  </Directory>

Make the default apache site be the bonnie provided content:

rm /etc/apache2/sites-enabled/000-default
ln -s ../sites-available/bonnie /etc/apache2/sites-enabled/000-default

Locate Ruby and Passenger directory

ls /usr/local/rvm/gem/
* Ruby directory should be similar to "ruby-2.0.0-p481" 

ls /usr/local/rvm/gem/[your ruby directory]/gem
* Passenger directory should be similar to "passenger-4.0.48"

Update the apache configuration with the following commands:

echo 'LoadModule passenger_module /usr/local/rvm/gems/[ruby directory]/gems/[passenger directory]/buildout/apache2/mod_passenger.so  > /etc/apache2/mods-available/bonnie.conf

echo 'PassengerRoot /usr/local/rvm/gems/[ruby directory]/gems/[passenger directory]' >> /etc/apache2/mods-available/bonnie.conf

echo 'PassengerRuby /usr/local/rvm/wrappers/[ruby directory]' >> /etc/apache2/mods-available/bonnie.conf
ln -s ../mods-available/bonnie.conf /etc/apache2/mods-enabled/bonnie.conf

Add a file (as root, using sudo -i):

/etc/apache2/conf.d/mod_passenger.conf 

With the following content (use output from passenger-install-apache2-module):

  LoadModule passenger_module /usr/local/rvm/gems/[ruby directory/gems/[passenger directory]/buildout/apache2/mod_passenger.so 
 <IfModule mod_passenger.c>
      PassengerRoot /usr/local/rvm/gems/[ruby directory]/gems/[passenger directory]
      PassengerDefaultRuby /usr/local/rvm/gems/[ruby directory]/wrappers/ruby
      PassengerMinInstances 4
      PassengerMaxPoolSize 4
      PassengerMaxRequests 1000
      PassengerPreStart http://localhost/
 </IfModule> 

Restart apache:

service apache2 restart

Exit the root shell:

exit

To open the Bonnie web app you'll need the server IP address from step 1.  The server IP address was found from the ifconfig command.  Open a web browser and enter

http://<server_ip_address from step 1>/

This should open the Bonnie web application.  Click on the "Register" link to add a new user and to get started with Bonnie

Once you have added a user you will need to change that user to an admin so that you can approve other users.

bundle exec rake bonnie:users:grant_admin EMAIL=<EMAIL> RAILS_ENV=production

Where is the email of the account you registered with your admin user.

Finally you need to approve your admin user:

mongo
use bonnie_production
db.users.update({email: '<EMAIL>'}, { $set: {admin: true}})
exit

Now you should be able to log into bonnie as an admin user.