I am having some permission issues with my site. I do not know a lot about vhosts (on the process of learning ) and apache directives. I am trying to run php as cgi and I have them with .cgi extension.

(I am trying to setup my personal server to do my school projects and the school project require .cgi extension for php - they work on school servers so i want to setup my server to do the same so that i can work on my own computer which is way faster than working on school servers)

My expectations:
* php run as cgi script, (php files with .cgi extensions)
* give 701 permissions for directories and .cgi files and 604 for others except for some php files which are accessed by the .cgi files themselves. I want 600 for these files
* site work with the above settings
What it currently does:
* php runs as cgi script with .cgi extensions, i added .cgi on AddHandler line, but it has to be 711 permission. if i give no permissions to group, it will not run.

I do not want to give any permission to group, and go with 701, 604 etc, how can i achieve that?

Another minor problem: the school servers check for the shebang line and if there is no shebang line, it gives error, mine just ignores shebang line and works without it, it is not that important for me, as i will be running it only web script, but will love to know how to do that.

here is my vhost file, please ask for more files if you need to see. (newbie, don't know much):

Please give me some suggestions and show me some path. I have other two hosts on the same server, one has joomla cms and other drupal and are running fine with fastCGI, but this one I need it to be slightly different. I found out the school server uses cgi/fastCGI also using phpinfo.