简体   繁体   English

如何检查远程服务器是否支持PHP?

[英]How to check if a remote server supports PHP?

I often have clients who do not know if their server supports PHP (their website is HTML web site). 我经常有客户不知道他们的服务器是否支持PHP(他们的网站是HTML网站)。 At the moment, I send them hello.php file, they upload it and then I check it remotely if their server supports PHP. 目前,我发送了hello.php文件,他们上传了它,然后如果他们的服务器支持PHP,我会远程检查它。 As you see this takes day or two and it's just a waste of time. 如你所见,这需要一两天,这只是浪费时间。

Can I myself any how check if their server supports PHP (via web browser or console tool)? 我可以自己检查他们的服务器是否支持PHP(通过网络浏览器或控制台工具)吗? If the domain is for example www.my-client.com, what would be the syntax? 如果域名是www.my-client.com,那么语法是什么?

Thanks 谢谢

PS. PS。 I have an access to Linux console so I could use it as well 我可以访问Linux控制台,所以我也可以使用它

The best you could do is send an HTTP request to this server http://www.my-client.com and inspect response HTTP headers. 您可以做的最好的事情是向此服务器发送HTTP请求http://www.my-client.com并检查响应HTTP标头。 In some cases depending on the server there might be clues. 在某些情况下,取决于服务器可能有线索。 For example here's how the response HTTP headers look like in FireBug for http://joomla.org : 例如,这里是针对http://joomla.org的 FireBug响应HTTP标头的样子:

在此输入图像描述

As Darin Dimitrov says some Servers promote the versions of the uses software. 正如Darin Dimitrov所说,一些服务器推广使用软件的版本。 You can use curl to view the HTTP Header of a response. 您可以使用curl查看响应的HTTP标头。

> curl -I http://example.com

HTTP/1.1 200 OK
Date: Tue, 17 May 2011 10:04:01 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch
X-Powered-By: PHP/5.2.4-2ubuntu5.10
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8

Can also try with 也可以试试

http://www.example.com/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42

Some servers will respond with a PHP image then. 然后,一些服务器将使用PHP映像进行响应。 If you have shell access, it is more reliable to test whether php in installed directly on the system though. 如果你有shell访问权限,那么测试php是否直接安装在系统上是更可靠的。 Whether PHP exposes if it is installed via this Easter Egg or via the Response Headers can be disabled in the PHP.ini. 如果PHP通过此复活节彩蛋安装或通过响应标头安装,则可以在PHP.ini中禁用它。

Read more at 了解更多信息

Decides whether PHP may expose the fact that it is installed on the server (eg by adding its signature to the Web server header). 决定PHP是否可以公开它安装在服务器上的事实(例如,通过将其签名添加到Web服务器头)。 It is no security threat in any way, but it makes it possible to determine whether you use PHP on your server or not. 它无论如何都不是安全威胁,但它可以确定您是否在服务器上使用PHP。

Not very reliable (but a quick check) is requesting a non existing path (404) returns information about the server and its setup. 不太可靠(但是快速检查)是请求非现有路径(404)返回关于服务器及其设置的信息。 For example, on my machine I get the following in the footer which I could parse for 'PHP': 例如,在我的机器上,我在页脚中得到以下内容,我可以解析'PHP':

Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 Apache / 2.2.14(Unix)DAV / 2 mod_ssl / 2.2.14 OpenSSL / 0.9.8l PHP / 5.3.1 mod_perl / 2.0.4 Perl / v5.10.1

In addition to Darin Dimitrov's answer I can say that you could read WHOIS information about the domain and detect where it is being hosted. 除了Darin Dimitrov的回答之外,我可以说您可以阅读有关域的WHOIS信息并检测它的托管位置。 Then, if you identify the hoster, simply check what features he offers. 然后,如果您确定了主机,只需检查他提供的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM