in reply to Apache reads scripts as html, not cgi

Without seeing your configuration, its hard to determine exactly what is wrong... However, it sounds like you might need to add:

AddHandler cgi-script .cgi
to your configuration file.

-Blake