You are calling your bash script with sh. This is usually a basic POSIX shell like dash. The [[ isn't POSIX, it's a bashism (also present in some other shells) so your sh doesn't support it:
$ dash -c "if [[ 10 -gt 8 ]]; then echo yeah; fi"
dash: 1: [[: not found
So, either change your script to use the standard [ (you're not using any special features of [[ anyway):
if [ -e /var/log/apache2/error.log ]; then
echo YES
fi
Or change your PHP script and call the script with bash explicitly:
$cmd = "bash myscript.sh";
or, since you do have a #!/bin/bash shebang, and assuming the script has the executable bit set, just call it directly:
$cmd = "myscript"./myscript.sh";