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

Installation Instructions

Ashok Dongare edited this page Mar 18, 2021 · 18 revisions

The installation will require the installation of the following components

  1. Ubuntu (these instructions are for Ubuntu version 14.04.5 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 14.04.5 LTS can be downloaded from the following URL: http://releases.ubuntu.com/14.04.5/

These instructions were developed against the "Server install image for 64-bit PC (AMD64) computers (standard download)" ISO file (ubuntu-14.04.5-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/14.04/serverguide/installation.html

Once Ubuntu has been installed, it is recommended you update the installed packages using APT (Advanced Packaging Tool). APT is the default 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 (if your Ubuntu installation did not include one by default). SSH 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

Typically, the primary interface will be labeled eth0, and your external IP address is listed under inet addr:.

  1. Configure Proxy Settings

This step is only required if the server you are installing Bonnie on 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 favorite 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
export http_proxy=http://<your.proxy.host.com>:<your.proxy.port>/
export https_proxy=http://<your.proxy.host.com>:<your.proxy.port>/
export HTTP_PROXY=http://<your.proxy.host.com>:<your.proxy.port>/
export HTTPS_PROXY=http://<your.proxy.host.com>:<your.proxy.port>/

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 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.7.2

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 super user privileges. An interactive super user privileged bash shell session 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.7.2 using RVM:

rvm install 2.7.2

Set the default ruby version to 2.7.2:

rvm --default 2.7.2

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

gem install bundler

Close the super user privileged bash shell session by running:

exit

Setup RVM for the current user:

source /etc/profile.d/rvm.sh
rvm use 2.7.2
rvm --default 2.7.2
  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.12

To test the mongo connection (wait at least 15 seconds to let the db start up), run the command below. If the command exits with an error about not being able to connect, reboot the server (sudo reboot). 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.8' -- --with-xml2-dir=/usr/local/lib --with-xml2-include=/usr/local/include/libxml2
exit
  1. Bonnie Source Code

Add a server user that Bonnie will run as

sudo adduser 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 
bundle exec rake db:setup RAILS_ENV=production
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.conf

With the following content (changing the path to point to where you cloned Bonnie 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>

OPTIONAL: If you want to be able to easily put Bonnie into maintenance mode, add the following lines to the previous file below the DocumentRoot Line:

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !/maintenance.html
RewriteRule ^.*$      /maintenance.html [L]

And run:

sudo a2enmod rewrite

Simply add a maintenance.html file in the Document Root to put Bonnie into maintenance mode (and remove it to leave maintenance mode).

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/gems
* Ruby directory should be similar to "ruby-2.7.2" 

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

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-available/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>

Then run:

sudo a2enconf mod_passenger
sudo a2dissite default
sudo a2ensite bonnie

Restart apache:

sudo service apache2 reload

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.