Rocky 9 httpd AH00558 서버 이름 경고 끄기
Rocky 9 httpd 의 AH00558 은 conf.d 에 전역 ServerName 파일 하나로 끕니다. 가상 호스트 안의 ServerName 만으로는 남고, FQDN 호스트 이름으로도 풀립니다.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message경고일 뿐이고 서버는 뜹니다. 경고와 오류를 가르는 법(Syntax OK·종료 코드·200 응답), 경고가 error_log 가 아니라 표준 오류·journalctl 에 나오는 점, httpd 가 이름을 정하는 순서는 Ubuntu 의 apache2 와 같으므로 Apache AH00558 서버 이름 경고 없애기를 봅니다. 이 글은 Rocky 9 에서 달라지는 곳만 다룹니다. Rocky 에는 a2enconf 가 없고, 설정은 /etc/httpd/ 아래에 있습니다.
[1] 기본 설정 파일에서 ServerName 자리와 추가 설정을 읽는 줄을 확인합니다. Rocky 의 httpd.conf 에는 100번째 줄에 주석 처리된 예시만 있고, 끝 부분에서 conf.d/*.conf 를 읽습니다.
# grep -n 'ServerName' /etc/httpd/conf/httpd.conf94:# ServerName gives the name and port that the server uses to identify itself.100:#ServerName www.example.com:80# grep -n '^IncludeOptional' /etc/httpd/conf/httpd.conf358:IncludeOptional conf.d/*.confconf.d/ 에 둔 .conf 파일은 켜는 단계 없이 바로 읽힙니다. 파일 이름이 .conf 로 끝나지 않으면 읽히지 않습니다.
[2] conf.d 에 전역 ServerName 을 넣습니다. 패키지가 관리하는 httpd.conf 를 직접 고쳐도 되지만, 별도 파일이면 무엇을 바꿨는지 한눈에 보이고 지우기만 하면 되돌아갑니다. 값은 이름[:포트] 이고 서버에서 IP 로 풀리는 이름을 씁니다.
ServerName www.example.com:80# httpd -t; echo $?Syntax OK0경고 줄이 사라지고 Syntax OK 만 남았습니다. 적용은 systemctl reload httpd 로 합니다. 시험에서는 httpd -k graceful 뒤 같은 200 응답을 확인했습니다. 되돌릴 때는 이 파일을 지우고 httpd -t 뒤 다시 reload 합니다.
[3] 가상 호스트에 ServerName 을 적어 두었어도 전역 줄은 따로 필요합니다. 전역 줄 없이 conf.d/vhost.conf 에 가상 호스트 하나만 두고 검사한 결과입니다.
# cat /etc/httpd/conf.d/vhost.conf<VirtualHost *:80> ServerName www.example.com</VirtualHost># httpd -tAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this messageSyntax OK경고는 그대로입니다. 이름 기반 가상 호스트를 여럿 두는 서버라면 [2] 의 파일을 함께 둡니다.
[4] ServerName 대신 호스트 이름을 FQDN 으로 풀리게 해도 경고가 나오지 않았습니다. 기본 컨테이너는 짧은 이름(hostname -f 도 server1)이라 경고가 났고, Docker --hostname web1.example.com 으로 띄운 컨테이너는 아래처럼 조용했습니다.
# hostname; hostname -fweb1.example.comweb1.example.com# grep web1 /etc/hosts192.0.2.10 web1.example.com web1# httpd -t; echo $?Syntax OK0실제 서버에서 이렇게 하려면 시스템 호스트 이름과 /etc/hosts 를 바꿔야 합니다. ⚠️ 호스트 이름은 메일 발송·모니터링 등록·클러스터 소속 같은 다른 프로그램도 씁니다. 웹 서버 경고만 끄려면 [2] 가 영향이 작습니다. 그래도 바꾼다면 먼저 원래 값을 남깁니다.
# hostnamectl hostname | tee /root/hostname.orig# cp -p /etc/hosts /root/hosts.orig# hostnamectl set-hostname web1.example.com/etc/hosts 에는 <서버의 실제 IP> web1.example.com web1 한 줄을 넣습니다. 위 출력의 192.0.2.10 은 문서용 주소이니 그대로 옮기지 않습니다. hostname -f 가 FQDN 을 돌려주는지 보고, httpd -t 뒤 systemctl reload httpd 합니다. 문제가 생기면 저장해 둔 값으로 되돌리고 다시 검사합니다.
# hostnamectl set-hostname "$(cat /root/hostname.orig)"# cp -p /root/hosts.orig /etc/hosts# hostname -f; httpd -tApache 로그를 브라우저에서 바로 분석 ↗ — 아무것도 올라가지 않습니다.