Installing Snippy on CentOS 5

I wanted to install something like Pastie at my workplace to easily share snippets of code privately, instead of sharing it to the whole wide world. There are some open source alternatives such as LodgeIt and pastebin but for some unknown reasons, I could never get it to set up properly.

Then I came across snippy (a clone/ripoff of Pastie as the author – Flinn Mueller puts it). Mueller provided some documentation on how to set up, but it wasn’t sufficient to set it up in CentOS. In addition, I had ZERO knowledge about running Ruby on Rails applications which might be another contributing factor to why I had so many issues setting it up. Here’s a guide on how I managed to set it up successfully on CentOS:

Getting everything that Snippy needs:

Install Ruby on Rails

Snippy runs on Ruby on Rails. If you do not have this installed, Slicehost has a great guide on how to install it.

Additional notes:

  1. The current release of rubygems is v1.3.5. Please grab the latest version when following Slicehost’s article.
  2. Snippy somehow would fail to install with the latest version of rails (v2.3.3). The following error will appear if you tried to install snippy:
    undefined method `make_cache_key' for class `MemCache'

    To solve this, in addition to all the steps you followed at Slicehost, do

    gem install -v=2.1.1 rails
    

Install Sphinx

wget http://sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz
tar xvfz sphinx-0.9.8.1.tar.gz
cd sphinx-0.9.8.1
./configure
make

(If you receive an error about command not found for g++), do:

yum install gcc-c++

Finally,

make install

Install Oniguruma

To have it working for snippy, I needed to install Oniguruma from 2 different sources. Why? I do not know since installing just either one of them would not get Snippy running. First, I obtain and installed the rpm for CentOS:

	wget ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/oniguruma-5.9.1-2.el5.kb.i386.rpm
	rpm -i oniguruma-5.9.1-2.el5.kb.i386.rpm

Next, I obtained the latest release from the Author’s site (http://www.geocities.jp/kosako3/oniguruma/)

wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.1.tar.gz
tar xvfz onig-5.9.1.tar.gz
cd onig-5.9.1
./configure
make
make install

The fun part – Snippy!!!

Most of the following steps follows what Mueller had outlined in his README.

git clone git://github.com/actsasflinn/snippy.git
cd snippy
cp config/database.yml.example config/database.yml
vi config/database.yml

Edit the config/database.yml to match your own db settings. You must include an additional parameter called “host” to get Snippy to work. E.g. For mine, I set the following for development, test and production:

adapter: mysql
encoding: utf8
database: snippy_development
username: myUser
password: myPassword
socket: /tmp/mysql.sock
host: 127.0.0.1

Next,

rake gems:install
rake db:create

You might get the an error “error with missing these required gems: oniguruma and textpow” after doing “rake db:create“. If so, do the following:

gem install -r textpow --include-dependencies

Then,

rake db:migrate
rake bootstrap
rake thinking_sphinx:configure
rake thinking_sphinx:index
rake thinking_sphinx:start
ruby script/plugin install git://github.com/rsl/acts_as_snook.git --force
./script/server

If all goes well, you should be able to launch your browser and go to http://YOUR_SERVER:3000 to see if you can start snipping. :D Big thanks to Meuller for this wonderful application!

One Comment

  1. rubiojr
    Posted July 27, 2009 at 3:59 am | Permalink

    There are RPM packages for sphinx at:

    http://centos.karan.org/el5/misc/testing/

    Cheers!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*