SAPI
acronymKept in this browser · My desk
Stands for: Server API
Server API: the layer that connects PHP to whatever started it, a web server, a FastCGI process manager or a terminal.
The function php_sapi_name() reports it: cli for the command line, fpm-fcgi for PHP-FPM, apache2handler for the Apache module, cgi-fcgi for php-cgi, among others. The SAPI decides when php.ini is read, which per-directory files apply and which processes hold PHP between requests, so it is the first thing to establish about any PHP server.
The PHP manual documents four in detail. The CLI is for shell scripts and cron jobs and lifts the max_execution_time limit; its built-in web server is for development only and should not be used on a public network. PHP-FPM is a FastCGI process manager with pools of workers. The Apache module embeds PHP in every httpd worker, and the manual now says not to use it for new installations. CGI starts an interpreter for each request.
Under FPM and the Apache module one parent coordinates children that each serve one request at a time and many requests over their lives, so anything a worker deliberately keeps, such as a persistent database connection, outlives the request that opened it. The Server API line of phpinfo() shows which SAPI answered a web request.
Also known as: server api, php_sapi_name, php sapi, mod_php, apache2handler, php cli
Sources
- PHP Manual, php_sapi_name: the Server API names, from cli and fpm-fcgi to apache2handler and cgi-fcgi (read 2026-10-27)
- PHP Manual, Persistent Database Connections: the CGI, FPM and module process models (read 2026-10-27)
- PHP Manual, Command line usage and Built-in web server (read 2026-10-27)
- PHP Manual, Apache httpd 2.x on Unix systems: "Do not use mod_php for new installations" (read 2026-10-27)