I think changing script owner to www-data will make your script executable.
In Linux, use chown to change script owner
chown www-data file.txt
This will change file.txt owner to www-data
chown -R www-data /files/work
Recursively grant ownership of the directory /files/work, and all files and subdirectories, to user www-data.
Linux chown command details
In PHP, you can use chown function to change ownership
<?php
// File name and username to use
$file_name= "foo.php";
$path = "/home/sites/php.net/public_html/sandbox/" . $file_name ;
$user_name = "root";
// Set the user
chown($path, $user_name);
// Check the result
$stat = stat($path);
print_r(posix_getpwuid($stat['uid']));
?>
Php chown details