Find out how PHP is running on server (CGI OR fastCGI OR mod_php)
Asked Answered
M

2

56

I use shared hosting.

There is possible to find out whether PHP is running via fastCGI (or maybe CGI) or as Apache module mod_php?

Is it possibly to find out by myself, without asking the hoster?

Minna answered 7/5, 2013 at 7:59 Comment(2)
You could upload a .php file containing <?php phpinfo(); and have a look at the loaded modules?Bedlam
Make sure to delete that file afterwards, especially if the website is going to be hosted online. It should never be hosted or accessible as it leaks valuable information to potential malicious users.Asturias
H
81

That's the Server API row on top of phpinfo()'s output:

Server API: Apache 2.0 Handler + CGI/FastCGI

However, please note that it won't necessarily tell you the exact version of Apache or the exact CGI handler. It just describes the SAPI in use.

You can also call the php_sapi_name() function (or the PHP_SAPI constant, which provides the same info):

Description

string php_sapi_name ( void )

Returns a lowercase string that describes the type of interface (the Server API, SAPI) that PHP is using. For example, in CLI PHP this string will be "cli" whereas with Apache it may have several different values depending on the exact SAPI used

It's still a good idea to check your HSP's documentation because it possible to have several PHP versions available.


Remember you need to run phpinfo() from the same environment you want to check (web server won't tell you about command line and vice-versa):

C:\>php -i | findstr /C:"Server API"
Server API => Command Line Interface
$ php -i | grep 'Server API'
Server API => Command Line Interface
Homiletic answered 7/5, 2013 at 8:25 Comment(0)
N
5

You can use the link below: How to determine php is running as php cgi or apache module?

or create a file info.php and type

<?php 
    phpinfo(); 
?>

now run file with your domain name.

find Server API on file and it show you PHP is running on server with CGI OR Apache

Security consideration: Make sure to delete the file which outputs phpinfo() especially if the website is or is going to be hosted online. The information shown there is a gold mine for hackers.

Ningsia answered 16/11, 2013 at 8:16 Comment(1)
The link returns an error.Viewless

© 2022 - 2024 — McMap. All rights reserved.