i am not an expert, but as far as i understood...
sapi is the channel through which the http server software communicates with cgi interpreter, that spawns an execution context (a shell, socket or port), read passed environment variables, read specified file (specified through environment variables, like SCRIPT_NAME), interprets the file and returns generated html code back to server to be delivered to http client (i.e. a browser)
in case of php, sapi could be...
- a shell/cmd instance, in case of cgi (php-cgi or php.cgi.exe in windows)
- a unix socket or pipe, in case of fastcgi (php-cgi or php[.exe])
- a tcp or unix socket, in case of fpm (php-fpm)
- some other channel i dont know
so for example, php error_log('my msg', 4)
will send the message back to webserver through "stderr" stream of current sapi, the webserver software will catch the message and will display in its own error log facility (/var/log/nginx/error.log
file in my case) as thrown by his cgi interpreter
i am not sure, correct me if i am wrong