Apache(httpd)와 PHP 버전 정보를 숨기는 방법
웹 서버와 PHP 버전 정보는 공격자에게 취약점 탐색 힌트를 제공할 수 있습니다. 따라서 운영 환경에서는 HTTP 응답 헤더에서 서버 및 PHP 버전 정보를 숨기는 것이 권장됩니다.
1. HTTP 헤더를 통한 서버 정보 확인 방법
wget 명령으로 확인
wget --server-response --spider localhost
Spider mode enabled. Check if remote file exists.
--2022-03-08 21:54:05-- http://localhost/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Tue, 08 Mar 2022 12:54:05 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.4.28
X-Powered-By: PHP/7.4.28
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.
- Apache 버전, OS 정보, PHP 버전이 모두 노출됨
curl 명령으로 확인
curl --head localhost
HTTP/1.1 200 OK
Date: Tue, 08 Mar 2022 12:56:46 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.4.28
X-Powered-By: PHP/7.4.28
Content-Type: text/html; charset=UTF-8
2. Apache(httpd) 버전 정보 숨기기
Apache 설정 파일(httpd.conf)을 수정합니다.
- ServerTokens Prod → Server: Apache 만 출력 (버전/OS 제거)
- ServerSignature Off → 에러 페이지 하단의 서버 정보 제거
vim httpd.conf
ServerTokens Prod
ServerSignature Off
3. PHP 버전 정보 숨기기
php.ini 경로 확인
php --ini | egrep "Loaded Configuration File"
Loaded Configuration File: /etc/php.ini
PHP 버전 노출 비활성화
sed -i "s/expose_php = On/expose_php = Off/g" /etc/php.ini
또는
vim /etc/php.ini
expose_php = Off
- X-Powered-By: PHP/x.x.x 헤더 제거
4. 설정 적용 (서비스 재시작)
systemctl restart httpd
PHP-FPM 서비스 재시작
systemctl restart php-fpm
5. 적용 후 HTTP 헤더 재확인
wget 확인
$ wget --server-response --spider localhost
Spider mode enabled. Check if remote file exists.
--2022-03-08 22:17:20-- http://localhost/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Tue, 08 Mar 2022 13:17:20 GMT
Server: Apache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.
curl 확인
$ curl --head localhost
HTTP/1.1 200 OK
Date: Tue, 08 Mar 2022 13:17:12 GMT
Server: Apache
Content-Type: text/html; charset=UTF-8
- Apache / PHP 버전 정보 완전히 제거됨
- X-Powered-By 헤더 미노출 확인
'리눅스' 카테고리의 다른 글
| [draft] PHP 서버 정보를 확인하는 방법 (0) | 2026.03.04 |
|---|---|
| [draft] CentOS 7에서 YUM을 이용한 APM(Apache · PHP · MariaDB) 설치하는 방법 (0) | 2026.03.04 |
| [draft] sudo 명령어 (1) | 2026.03.03 |
| [draft] 우분투에 Nginx와 ModSecurity를 설치하고 OWASP ModSecurity CRS를 적용하는 방법 (0) | 2026.03.03 |
| [draft] CentOS 8 Docker 컨테이너에서 systemctl 사용하기 (0) | 2026.03.03 |