If you want to continue with FPM, you need ob_end_clean before first echo but with enough count, so the final status may be like this
<?php
while (ob_get_level()) ob_end_clean();
for ($i = 1; $i <= 10; $i++){
sleep(1);
echo "$i\n";
ob_flush();
flush();
}