CentOS 8でApacheをインストール後、Apacheが起動せずに以下のエラーが出た時の原因、対策、解決策をまとめた。
1 2 |
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message |
ApacheがAH00558エラーで起動しない原因
CentOS 8でApacheをインストール後に起動してみると以下のエラーが出ました。
1 2 3 |
# systemctl start httpd.service Job for httpd.service failed because the service did not take the steps required by its unit configuration. See "systemctl status httpd.service" and "journalctl -xe" for details. |
メッセージ通りに、systemctl status httpd.service を実行してみます。
1 2 3 4 5 6 |
Systemd[1]:Starting The Apache HTTP Server ... httpd[11412]:AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message httpd[11412]:http (pid 7407) already running systemd[1]:httpd.service: Failed with result 'protocol'. systemd[1]:Failed to start The Apache HTTP Servier. |
なるほど、このエラーを無くすには、Apacheの設定で ServerName ディレクティブを設定すればよいようです。
ApacheのAH00558エラーの解決策
Apacheの設定を編子するには、/etc/httpd/conf/httpd.conf を開きます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 ServerName localhost:80 # # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. # <Directory /> AllowOverride none Require all denied </Directory> |
先頭から98行目ぐらい
「#ServerName www.example.com:80」という行のコメントの下に現在利用中のドメイン(又はホスト名)を記入して保存します。
今使っているのがローカルテスト環境だったので
ServerName localhost:80
としました。
Apacheを起動してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[root@localhost conf]# systemctl start httpd.service [root@localhost conf]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d └─php-fpm.conf Active: active (running) (thawing) since Sat 2023-04-08 13:22:26 JST; 11s ago Docs: man:httpd.service(8) Main PID: 2968 (httpd) Status: "Running, listening on: port 80" Tasks: 213 (limit: 49335) Memory: 35.5M CGroup: /system.slice/httpd.service ├─2968 /usr/sbin/httpd -DFOREGROUND ├─2969 /usr/sbin/httpd -DFOREGROUND ├─2970 /usr/sbin/httpd -DFOREGROUND ├─2971 /usr/sbin/httpd -DFOREGROUND └─2972 /usr/sbin/httpd -DFOREGROUND 4月 08 13:22:26 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... 4月 08 13:22:26 localhost.localdomain systemd[1]: Started The Apache HTTP Server. 4月 08 13:22:26 localhost.localdomain httpd[2968]: Server configured, listening on: port 80 |
エラーが修正されてApacheが起動しました。
コメント