How to know for sure if FastCGI is being used to run php scripts
php_sapi_name() or PHP_SAPI, both work.
http://php.net/manual/en/function.php-sapi-name.php
<?php
if (php_sapi_name() != 'cgi-fcgi'){
echo 'I knew fastcgi wasn\'t working.';
}else{
echo 'Holy crap, something worked for once.';
}
Here's a simple test:
- Create a phpinfo.php file with
<?php phpinfo(); ?>
inside;
Request http://yoursite.com/phpinfo.php/foobar?foo=bar
Check the output of phpinfo and look for _SERVER["REQUEST_URI"].
If this variable is missing, then CGI is used. If the variable is present and correctly set to /phpinfo.php/foobar?foo=bar, then either ISAPI or FastCGI is used. Look near the top of the output for Server API; it should be set to either ISAPI (which means ISAPI is being used) or CGI/FastCGI (which means FastCGI is being used, since we already ruled out CGI).
You can use (on centos) apachectl -M
, you'll show what modules are enabled:
apachectl -M:
file_cache_module (shared)
mem_cache_module (shared)
version_module (shared)
fastcgi_module (shared)