index of显示apache和php版本信息
问题描述
大神们,在图中红框这个地方把apache和php版本信息显示出来,apache是哪个配置项
问题解答
回答1:你所看到的这个文件目录直接显示的页面,是Apache的 mod_autoindex 模块负责处理的。
先说说之前别人提到的那个ServerSignature 和 ServerTokens
ServerTokens FullServerSignature On
mod_autoindex 的末尾信息:Apache/2.4.10 (系统 Debian/Ubuntu/Windows之类的) OpenSSL/1.0.1t Server at your.domain.com Port 443
Http头部:Server:Apache/2.4.10 (系统 Debian/Ubuntu/Windows之类的) OpenSSL/1.0.1t
ServerTokens ProdServerSignature Off
是这个样子的:
mod_autoindex 的末尾信息:Apache Server at your.domain.com Port 443
Http头部:Server:Apache
所以 ServerSignature 和 ServerTokens 和你的问题没什么直接关系。
也就是说,Apache没有什么配置项能直接解决这个问题(Apache又不是必须和PHP结合,安装了Apache人家凭什么给你顺便显示PHP的信息?)。
间接解决:我给的是Debian/Ubuntu系+mod_php的解决方案,别的系统估计也类似。
/etc/apache2/mods_enabled/autoindex.conf
</IfModule>前面加上:
AddHandler application/x-httpd-php .phpAddType text/html .phpReadmeName /README.php HeaderName HEADER.html
ReadmeName 和 HeaderName 可能已经存在,那就改掉。
然后在你网站的根目录(your.domain.com/ 对应的那个目录)建立README.php
内容:
<?phpecho apache_get_version().’, PHP Version:’.phpversion();?>
注意啦,这里有个唯一可能跟 ServerTokens 有关的内容,如果你配置的是 Prod, 则只能显示出来Apache, 如果配置的是 Full 就会显示我之前提到的那一大串详细信息:
Apache/2.x.xx (系统 Debian/Ubuntu/Windows之类的) OpenSSL/1.0.xx
另外如果直接在php里调用shell_exec获得Apache版本号的话应该没有限制,可以不动ServerTokens配置。
更多参见:
Apache mod_autoindex 对于Header和Readme的详细说明PHP 函数,获得Apache版本信息PHP 获得PHP版本信息要在调用这个PHP之前声明.php的Handler。尽管你在别处可能也有声明,但是这个配置文件被Apache处理的顺序比较靠前。所以要更提前的声明不同的ServerTokens显示出来的信息都长啥样
回答2:这个主要涉及两个配置 ServerSignature 和 ServerTokens , ServerSignature 起开关作用,ServerTokens 控制显示信息多少。修改 httpd.conf 这两个配置为以下,然后重启就可以显示。
ServerSignature OnServerTokens Full
附两个配置的相关值
ServerSignature : Off | On | Email
ServerTokens : Prod | Major | Minor | Min | OS | Full (显示内容从小到多)
相关文章:
1. angular.js - 请教angularjs里html和js通信的问题2. node.js - 怎么在初始化的时候使得一个子组件不加载?3. android自带时钟应用的这个效果是怎么做的4. 代码如下,java用BigDecimal四舍五入怎么还有问题呀?哪种方式是完全没有问题的?5. javascript - 关于向java后台上传base64位字符串的图片数据,求助6. 求解决方法:Parse error: syntax error, unexpected7. 新人做网站求帮助8. 老师所用的IDE开发环境是什么?9. 请问“由于 Cookie “PHPSESSID”的“SameSite”属性设置为“None”,但缺少“Secure”属性,此 Cookie 未来将被拒绝。”请问出现这个问题怎么办?10. Help!求帮助