How to Determine PHP Engine Execution: CGI, FastCGI, or Mod_PHP
If you use shared hosting and want to ascertain how PHP is operating on the server without reaching out to the hoster, you can investigate yourself.
Server API
Execute phpinfo() to obtain insight into the PHP environment. The desired information can be found under the "Server API" row. This will typically display "Apache 2.0 Handler CGI/FastCGI," indicating the specific SAPI (Server API) in use.
PHP_SAPI_NAME Function
Alternatively, utilize the php_sapi_name() function or the PHP_SAPI constant. For instance, "cli" is returned while operating in CLI mode, while Apache may produce varied values based on the employed SAPI.
Note: The provided information might not always specify the precise Apache version or CGI handler but merely portrays the SAPI in use.
Consult Hosting Provider's Documentation
Referencing your hosting provider's documentation can be useful as multiple PHP versions might be accessible.
Run PHPinfo() from the Appropriate Environment
It's essential to execute phpinfo() within the context you wish to examine. For instance, running it through the command line won't offer insights into the web server.
The above is the detailed content of How Can I Tell If My PHP is Running with CGI, FastCGI, or Mod_PHP?. For more information, please follow other related articles on the PHP Chinese website!