You might have read about implementing Captcha on your website using a Ruby on Rails gem called Turing in my earlier blog post. Turing is really very good captcha system suited for my needs and may be many of yours.
Recently I have faced an issue with Turing on 64 bit machine (server, where I host my website). It did throw "500 an internal server error" when trying to access a webpage which shows captcha image using Turing, while the webpage used to work perfectly on i386 machine locally. I tried running the code manually from the console and it did gave "/usr/lib/ruby/gems/1.8/gems/gd2-1.1.1/lib/gd2/font.rb:234: [BUG] Segmentation fault" error indicating some issue with gd2 font.rb file.
After digging through the error message I came across two important urls that had solved the problem. The urls to refer are:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/227097
https://boxpanel.blueboxgrp.com/public/the_vault/index.php/Turing_Gem
The problem isn’t exactly within Turing or gd2 gem but ruby needs a better code to work with these gems.
URLs above describe the problem, reason of the problem and solution as well. Tried to write them in a much simpler way, that could ease the process of getting the problem solved.
## 1. Download the latest ruby source code instead of ruby-1.8.6.tar.gz
wget -q ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz## 2. Extract the downloaded tarball
tar xzf ruby-1.8.6.tar.gz## 3. Change directory to extracted source
cd ruby-1.8.6## 4. Change directory to place where the patch has to be applied
cd ext/dl## 5. Make a backup of original file where the patch is going to be applied
cp sym.c sym.c.orig## 6. Download the patch
wget http://www.ankit644.com/ror/sym.c.patch## 7. Apply a patch
patch sym.c sym.c.patch## 8. Change directory to parent directory
cd ../../## 9. Configure with below command
./configure –prefix=/home/local –enable-pthread –with-readline-dir=/home/local## 10. Make the binaries
make## 11. Install the binaries to your system.
make install
When your website is on a shared hosting web server, your hosting provider will not allow you to install a custom patch for solving an individual needs. So, you have to install custom ruby in your local directories and make your custom settings. e.g.
- Installing newly compiled ruby into your local directories (as per ‘make’ and ‘make install’)
- $PATH environment variable should take your custom built ‘ruby’ command
-
"#!/usr/bin/ruby"(a shebang line) in public/{dispatch.cgi, dispatch.fcgi} has to be changed to"#!/home/local/bin/ruby"
And you are done!
Please do provide your feedback, if you think issue could be solved in a better way.
Thanks for reading!
Ankit