Normally it if works from ssh and not the browser it *can* be a simple issue like the wrong chmodding or directory permissions. Have you checked all those?....or even typos in the shebang line?
Make sure the directory gforum.cgi is in is 0755, make sure gforum.cgi is 0755 too
Make sure the directory gforum.cgi is in is 0755, make sure gforum.cgi is 0755 too