Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

apache - Find out how PHP is running on server (CGI OR fastCGI OR mod_php)

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?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Server API: Apache 2.0 Handler + CGI/FastCGI

image

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...