了解 PHP 如何在服务器上运行(CGI 或 fastCGI 或 mod_php) [英] Find out how PHP is running on server (CGI OR fastCGI OR mod_php)

查看:29
本文介绍了了解 PHP 如何在服务器上运行(CGI 或 fastCGI 或 mod_php)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用共享主机.

有可能找出 PHP 是通过 fastCGI(或 CGI)运行还是作为 Apache 模块运行 mod_php?

可以不问房东自己找吗?

解决方案

那是 函数(或 PHP_SAPI 常量,提供相同的信息):

<块引用>

说明

string php_sapi_name ( void )

返回描述接口类型的小写字符串(PHP 正在使用的服务器 API、SAPI).例如,在 CLI PHP 这个字符串将是cli"而对于 Apache,它可能有几个不同的值取决于所使用的确切 SAPI

检查您的 HSP 文档仍然是一个好主意,因为可能有多个 PHP 版本可用.


请记住,您需要在要检查的同一环境中运行 phpinfo()(Web 服务器不会告诉您有关命令行的信息,反之亦然):

C:\>php -i |findstr/C:服务器API"服务器 API =>命令行界面

$ php -i |grep '服务器 API'服务器 API =>命令行界面

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?

解决方案

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

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

这篇关于了解 PHP 如何在服务器上运行(CGI 或 fastCGI 或 mod_php)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆