Tuesday, 27 June 2017

This tutorial will demonstrate how to build and configure Snorby on CentOS 7.Fornote: I will initally be disabling SELinux for the installation of Snorby - however at the end we will re-enable it and adjust the relevant rules in order to get it running nicely with Snorby.

Lets firstly install the libraries needed to compile some of the ruby gems:

yum install mysql-devel libpqxx-devel ruby-devel

cd /tmp
yum install ruby
gem update
gem install rails

(Again - I had to install an older version of rails in order to get it working with Ruby 1.9.3)

We'll now edit the database configuration - ensuring the 'adapter' variable is set to 'postgresql', user and passwords are set accordingly etc.

cp database.yml.example database.yml

and then run the Snorby setup with:

rake snorby:setup

We'll now attempt to start the rails application in production mode:

cd config
sudo rails s -e production

With any luck you should now be able to access Snorby on http://<ip>:3000

The default username / password is: snorby@example.com / snorby.

Once logged in go to 'Administration' >> 'Worker and Job Queue' and ensure the work has started.

Our next step is to configure nginx with passenger so we can let nginx server our pages. However we will either need to compile passenger and nginx from scratch or we can use the Phusion Pasenger repository - which in this case to save time (and my sanity) we will do:

When initially attempting access the site it bombed out and after going through the nginx error logs the following line caught my attention:

Missing proper 'which' command. Make sure it is installed before using RVM!
and also lines like (which was causing the Snorby Worker process from starting):

stderr: sh: env: command not found
Now - I was pretty sure this was already installed - and to confirm we can check with:

rpm -qa which

which-2.20-7.el7.x86_64
So my next though was that it was likely an environment variable (specifically PATH) issue. It turns out nginx (by default) 'nukes' all environment values and in order to preserve them (specifically 'PATH' in this case) we need to add the following to the 'http' stanza in nginx.conf:

env PATH;

and reload:

sudo service nginx reload

Although the above may seem pretty trivial it actually look me a while to get it all up and running with a lot of trial and error - I really hope the developers will streamline the process and fix a number of outstanding bugs as I can imagine a lot of people would be put of my the amount of work involved getting it running!

Performing a hard resetIf you want to start from scratch or simply just purge the snorby database you can do so by doing: