Indeed. The crux of your question, Dofski, is: “how do I get Apache to run my CGI program, and give me its output, instead of just showing me its source code?”
And my short but sincere answer to that question is ... “Google that.” The question is entirely programming-language independent, and it is definitely a FAQ. For instance, http://httpd.apache.org/docs/2.0/howto/cgi.html, or http://forums.devarticles.com/web-server-configuration-51/php-pages-won-t-load-show-source-code-apache-2t-52648.html, or maybe https://www.linuxquestions.org/questions/linux-software-2/apache-cgi-problem-browser-not-running-script-130250/.
Typically, the CGI-script material is placed in a certain <Location> in which an AddHandler directive tells Apache to recognize certain filetypes as being CGI scripts that are to be run, along with additional information that specifies exactly how to run them. Absent such directives, Apache treats everything as text to be served.