웹서버에서 PHP 버전을 숨기는 방법
1. 기본으로 셋팅시에는 PHP 버전이 노출이 된다
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@xinet ~]# curl -IL https://xinet.kr --insecure HTTP/1.1 200 OK Server: nginx Date: Fri, 29 Apr 2022 05:45:03 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive X-Powered-By: PHP/7.3.33 Set-Cookie: PHPSESSID=so4c1q4plhf12d05t72mrcl53b; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache Link: <https://xinet.kr/index.php?rest_route=/>; rel="https://api.w.org/" |
2. 버전 정보를 숨기기 위해서 php.ini 파일을 열어서 expose_php 값을 Off 로 수정한다
1 2 3 4 5 |
[root@xinet ~]# vi /usr/local/php-fpm/etc/php.ini ;expose_php = On expose_php = Off |
3. php 재시작 , 만약 php가 apache, nginx에 모듈로 동작이 된다면 웹서버 재시작
1 2 3 4 |
[root@xinet ~]# systemctl restart php-fpm ### 모듈형태 [root@xinet ~]# systemctl restart httpd |
4. 이제 다시 확인
1 2 3 4 5 6 7 8 9 10 11 |
[root@xinet ~]# curl -IL https://xinet.kr --insecure HTTP/1.1 200 OK Server: nginx Date: Fri, 29 Apr 2022 05:47:38 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Set-Cookie: PHPSESSID=asi36g9177ormfbgoq3tpbqei0; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache Link: <https://xinet.kr/index.php?rest_route=/>; rel="https://api.w.org/" |