When I open that page the Arduino restarts, so there seems to be some kind of access.

That is the normal behavior when opening the serial port.

It resets on close, too.

I'm aware of that, that's what I was trying to stop by disabling hupcl. Sorry, if I did not make myself entirely clear. I was just pointing out that the initial access works and that the problem seems to occur at a later stage.

I've stripped the code down because it already fails at opening the stream.

All that that code does is reset the Arduino twice.

There are a couple of ways to prevent the Arduino from being reset. It's more normal, though, to simply plan for that happening. Don't open and close the port every time you want to talk to the Arduino. Wait, after opening the serial port for the Arduino to reset before trying to talk to it.

Warning: fopen(/dev/tty.usbmodem621) [function.fopen]: failed to open stream: Device not configured in /Applications/XAMPP/xamppfiles/htdocs/index.php on line 2error opening streamWarning: fclose() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/index.php on line 5

Maybe I'm just being really stupid here, but I would kind of expect the Arduino to reset, wait two seconds and reset again. Which should free up the connection and allow me to connect again. Something goes wrong while executing fopen.