Sounds like it's a file permissions problem. On my system (ubuntu) apache runs as the user "www-data". Check if you have this user as well:
cat /etc/passwd | grep www
and if you do then likely you need to set the script so that the group "www-data" can execute it.
chown :www-data <your-script> && chmod 755 <your-script>
You may need to change the library so it can be read by this group, not sure.