Removing the fclose() does not change anything. Except that I get 1 less warning when I finally pull the plug.
But you are on to something with the parameters. I tried setting them just before fopen() with:
exec("stty -f /dev/tty.usbmodem621 cs8 9600 -hup ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts");
but that did not work. (The parameters are from: Arduino Playground - HomePage)
Opening the Arduino serial-monitor first (and keeping it open) and then calling the PHP script causes the it to terminate without errors though.
So I tried this next script with the serial-monitor open and it did turn the LED on after 2 seconds. Using the serial monitor to send and receive commands worked as well.
<?php
$f = fopen("/dev/tty.usbmodem621", "w");
sleep(2);
fwrite($f, '1');
fclose($f);
?>
The problem is that I can't get stty to change any values for me, because keeping the serial-monitor open is kind of inconvenient.