Apache can of course write and create files provided the directory permissions are set appropriatly. You can make them group owned by www and give whatever permission you want to owner/other.
If you need the cgi to run as a user, then either use suexec, or a setuid program that performs the operations. There are security considerations in either case, and there is no short, easy way to describe them. You're going to have to learn about setuid regardless, but start with
http://httpd.apache.org/docs/2.2/suexec.html.