CGi script is executed successfully if it is running in 1 thread per a website. However it fails with '500 - internal server error' while running in several concurrent threads.
POA limits the number of the concurrent threads during CGI scripts execution with the use of RLimitNPROC directive. Its value is calculated from the Maximum number of processes per website (units) and Limit of simultaneous requests per Virtual Host activation parameters as described in the POA Provider Guide - Specifying Basic Service Template Parameters.
Increase number of the concurrent threads during CGI scripts execution in POA Resource Types and/or Service Template.