You'll want to check out one of the many Ruby web frameworks. If all you
want is something simple like this, I'd suggest using Sinatra:
http://sinatrarb.com/

Since you're using Apache, I'd suggest phusion passenger to get it talking
with Sinatra: http://www.modrails.com/