Trap for young players. Ubuntu replaces the default interpreter for /bin/sh from Bash to Dash. This was done for performance reasons, but certain scripts really don’t like this. You can easily change it back with;
sudo dpkg-reconfigure dash
Information about this can be found here. This was done quite a long time ago, apparently, but for whatever reason scripts that ultimately wind up calling the PHP 7.1 interpreter while under Dash break badly under some circumstances (resulting in PHP segfaulting).