Linux — how to know if php run as cgi or module

For some reason you want to know how is php working with web server like apache. if you are the people who config the server,you got the answer in your head. what if you are not? well,php have a function for this:

php_sapi_name

Per php manual,call this function will returns the type of interface between web server and PHP

[codesyntax lang=”php”]

<?php
php_sapi_name();
?>

[/codesyntax]

The section below is take from the php manual:
Although not exhaustive, the possible return values include aolserver, apache, apache2filter, apache2handler, caudium, cgi (until PHP 5.3), cgi-fcgi, cli, continuity, embed, isapi, litespeed, milter, nsapi, phttpd, pi3web, roxen, thttpd, tux, and webjames.

When php run in CGI mode( or any other mode other that module mode), you can not set php config via php_value directive in the .htaccess file.

you can also take a look at the phpinfo page to decide how php is working with your webserver.