I think you can bring specific access to user and command with visudo
something like this:
nobody ALL = NOPASSWD: /path/to/osascript myscript.scpt
and with php:
@exec("sudo /path/to/osascript myscript.scpt ");
supposing nobody
user is running apache.