Snorby in CentOS 6.5

snorby_newHi, this is me again. This time I’m offering an update of my old post about how to install Snorby on CentOS as some readers have found some errors and problems. Though I’ve created this post for CentOS 6.5, this article may help you also if you’re trying to install Snorby on CentOS 6.4.

Now it’s easier to use wkhtmltopdf and I’ve also added a section to make the installation of ruby cleaner. Ok let’s start!

First, we’re installing some packages and we’re also going to install the EPEL repository.

yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum groupinstall "Development Tools"
yum install openssl-devel readline-devel libxml2-devel libxslt-devel mysql mysql-devel mysql-libs mysql-server urw-fonts libX11-devel libXext-devel fontconfig-devel libXrender-devel unzip wget xorg-x11-server-Xvfb libyaml libyaml-devel gdbm-devel tcl-devel db4-devel libffi-devel 

Now we are going to download and compile ImageMagick.

cd /opt
wget http://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd ImageMagick-*
./configure
make
make install
ldconfig /usr/local/lib

OK, time for wkhtmltopdf. In the past I had problems with the static version, that’s why I decided to compile it. The latest version works fine for me. Visit http://wkhtmltopdf.org/ and download the latest wkhtmltopdf for your Linux architecture 32 bits or 64 bits. I’m using the 64 bits version.

cd /opt
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
tar xvf wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
ln -s /opt/wkhtmltox/lib/libwkhtmltox.so.0 /usr/local/lib64/libwkhtmltox.so.0
ln -s /opt/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
ldconfig /usr/local/lib64

Thanks to this article I’ve used the instructions to create the rpm package for Ruby 1.9.3

cd /root
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p484.tar.gz -P rpmbuild/SOURCES
wget https://raw.github.com/imeyer/ruby-1.9.3-rpm/master/ruby19.spec -P rpmbuild/SPECS
rpmbuild -bb rpmbuild/SPECS/ruby19.spec
yum localinstall /root/rpmbuild/RPMS/x86_64/ruby-1.9.3p484-1.el6.x86_64.rpm

Now we’re going to install bundler and Snorby

cd /opt
gem install bundler
wget -O snorby.zip --no-check-certificate https://github.com/Snorby/snorby/archive/master.zip
unzip snorby.zip
cd snorby-master

I’ve created an empty database for Snorby and I’ve configured a user with permissions for that database:

# mysql -u root -p 
Enter password: 
mysql> create database snorby; 
Query OK, 1 row affected (0.14 sec) 
mysql> grant all privileges on snorby.* to snorby@localhost identified by 'snorby'; 
Query OK, 0 rows affected (0.06 sec) 
exit

We’ve to create a database.yml config file and edit it. We’ll add the database password, the name of the database and the MySQL server hostname or IP address:

cp config/database.yml.example config/database.yml

//This is the content of my file
snorby: &snorby 
 adapter: mysql 
 username: snorby 
 password: "snorby" 
 host: localhost

OK, I hope you’re following and you’ve no errors so far. Edit the Gemfile file and follow these instructions:

Change: gem 'rake', '0.9.2' to gem 'rake', '> 0.9.2' 
Add: gem 'thin' after gem 'json' so it shows like this:
gem 'json', '~> 1.7' 
gem 'thin' 
Comment the gem 'thin' line inside the group(:development) using a #. The files will look like this:

group(:development) do 
        gem "letter_opener" 
#  gem 'thin' 
end 

Add: gem 'orm_adapter' after gem 'netaddr' so it shows like this:
gem 'netaddr','~> 1.5.0' 
gem 'orm_adapter'

We’re close. Edit the Gemfile.lock file.

Change the line rake (0.9.2) to rake (0.9.2.2)

We need a snorby_config.yml. Then you can edit thing like the domain for your Snorby installation. You have more information about configuration in Snorby’s official page.

cp config/snorby_config.yml.example config/snorby_config.yml

Let’s install Snorby. If installation is successful we’ll launch it using the thin server (thanks for the tip Mephux and of course thank you for Snorby)

bundle install
rake snorby:setup
rails server thin -e production

If everything is fine you’ll have Snorby listening on 0.0.0.0:3000, if you want to open the port use this iptables rule (adjust it for your needs of course 🙂 )

iptables -I INPUT -p tcp --dport 3000 -m state --state=NEW,ESTABLISHED,RELATED -j ACCEPT

And that’s it! Snorby is showing the login (user: snorby@snorby.org password: snorby) and the export to PDF function is working for me. I’ll try to offer more information about Snorby in the future.

Thank you Parvez and W.White for your comments and please let me know if you find errors.

Cheers!

Advertisements