Ok, that suggests your next step. What are the permissions on /var/www/web5/cgi-bin? Is it by any chance world writeable? If so, try changing the permissions to something like 755 or 775 (looks like mine at 775).
To check whether this is it, after changing the permissions just run the script from the command line and see if reports the same error.