Archive for category Web Development

Re-enabling mod_ruby on perlninja.pl

I finally managed to re-enable mod_ruby on my server once again. This time around, I had a hard time enabling eRuby to work in Apache.

New Apache configuration file:

AddType text/html .rhtml
LoadModule ruby_module modules/mod_ruby.so
#<IfModule mod_ruby.c>
RubyRequire apache/ruby-run
RubyRequire apache/eruby-run
<Files *.rb>
Options +ExecCGI
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
<Files *.rhtml>
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
</Files>
#</IfModule>

The Apache eRuby SetHandler (rhtml) was not able to render any html/ruby pages, while regular ruby scripts (.*rb) were able to run just fine.

Apache log error:
[Sun Aug 08 20:56:15 2010] [error] mod_ruby: (eval):45: (eval):45: uninitialized constant Apache::ERubyRun (NameError)

FIX:

Specify the absolute path to the eRuby Apache module in /usr/lib/ruby/1.8/apache/eruby-run.rb.

Change  line 45

require ‘eruby’

to

require “/usr/lib/ruby/1.8/i386-linux/eruby.so”

Restart Apache and eRuby should render html/ruby pages as expected.

I hope people find this useful (and save a headache) as I spent about 5 hours researching this problem and I wasn’t able to find this fix anywhere.

mod_ruby and eRuby

I finally had some time to install mod_ruby and eRuby on my server.

Prerequisites:
httpd-devel ruby ruby-devel eruby
yum install httpd-devel ruby ruby-devel eruby

Installing mod_ruby was pretty confusing, as module default compilation is intended for Apache 1.3 (not why this is the case)

If you’re running Apache 2.0 or higher, I managed to successfully compiled mod_ruby as the following:
./configure.rb –with-apr-includes=/usr/include/apr-1
make
make install

After the install, then its a matter of just adding the custom ruby http conf file to httpd conf.d directory.

SAMPLE:

AddType text/html .rhtml
LoadModule ruby_module modules/mod_ruby.so


RubyRequire apache/ruby-run
#RubyRequire apache/ruby-debug

RubyRequire apache/eruby-run
#RubyRequire apache/eruby-debug

# Execute *.rbx files as Ruby scripts

Options ExecCGI
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
#RubyHandler Apache::RubyDebug.instance

# Handle *.rhtml files as eRuby files

SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
RubyHandler Apache::ERubyDebug.instance


Now I can embed Ruby code on standard html pages serving and running natively using Apache and eRuby. :-)
Hence, perlninja.pl

References:
http://www.modruby.net/en/
http://www.ptwit.ac.th/seksan/blog/?p=59

WordPress Upgrade

WordPress upgrade went real smooth. At a glance, WordPress 1.4 and 2.9 seem to be worlds apart.