如何在Linux伺服器中隱藏PHP版本

2 贊 回覆發表於2015-04-01
作者: skytech 譯者: LCTT geekpi

| 2015-04-01 08:00   評論: 4 分享: 9    

通常,大多數預設設定安裝的web伺服器存在資訊洩露,這其中之一就是PHP。PHP 是如今流行的服務端html嵌入式語言(之一?)。在如今這個充滿挑戰的時代,有許多攻擊者會嘗試發現你服務端的漏洞。因此,我會簡單描述如何在Linux伺服器中隱藏PHP資訊。

預設上expose_php預設是開的。關閉“expose_php”引數可以使php隱藏它的版本資訊。

[root@centos66 ~]# vi /etc/php.ini

在你的php.ini, 定位到含有expose_php的那行把On設成Off:

expose_php = Off

在此之前,web伺服器頭看上去就像這樣:

[root@centos66 ~]# curl -I http://www.ehowstuff.com/

HTTP/1.1 200 OK
Server: nginx
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.3
X-Pingback: http://www.ehowstuff.com/xmlrpc.php
Date: Wed, 11 Feb 2015 14:10:43 GMT
X-Page-Speed: 1.9.32.2-4321
Cache-Control: max-age=0, no-cache

更改並重啟 Web 服務後,php就不會在web服務頭中顯示版本了:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 11 Feb 2015 15:38:14 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
X-Pingback: http://www.ehowstuff.com/xmlrpc.php
Date: Wed, 11 Feb 2015 14:10:43 GMT
X-Page-Speed: 1.9.32.2-4321
Cache-Control: max-age=0, no-cache

LCTT譯註:除了 PHP 的版本之外,Web 伺服器也會預設洩露版本號。如果使用 Apache 伺服器,請參照此文章關閉Apache 版本顯示;如果使用 Nginx 伺服器,請在 http 段內加入server_tokens off; 配置。以上修改請記得重啟相關服務。


via: http://www.ehowstuff.com/how-to-hide-php-version-in-linux/

作者:skytech 譯者:geekpi 校對:wxy

本文由 LCTT 原創翻譯,Linux中國 榮譽推出

如何在Linux伺服器中隱藏PHP版本

相關文章