You can always put the CGI program in cgi-bin directory inside the DocumentRoot directory. Check for the ScriptAlias directive in Apache configuration file httpd.conf
Once you've determined/setup the cgi-bin directory and configured Apache, you should be able to run CGI programs via the browser.
Since you're planning on doing this using PHP, you need to check for PHP exec function,