VirtualHost confファイルを追加した後、Apacheは再起動されません。なぜですか?

VirtualHost confファイルを追加した後、Apacheは再起動されません。なぜですか?

サーバーのCentOS 7下部にインクルードファイルを追加した後に入力すると、次のエラーが発生します。sudo apachectl restarthttpd.conf

Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.

これを入力すると、sudo systemctl status httpd.service -l結果は次のようになります。

httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: failed (Result: exit-code) since Tue 2014-12-23 20:10:37 EST; 2min 15s ago
  Process: 2101 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 2099 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 2099 (code=exited, status=1/FAILURE)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"

Dec 23 20:10:37 ip-address httpd[2099]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e23f:49ff:feb7:2a21. Set the 'ServerName' directive globally to suppress this message
Dec 23 20:10:37 ip-address systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Dec 23 20:10:37 ip-address systemd[1]: Failed to start The Apache HTTP Server.
Dec 23 20:10:37 ip-address systemd[1]: Unit httpd.service entered failed state.

apacheインクルードディレクティブをコメントアウトすると再起動でき、インクルードディレクティブのコメントアウトを削除するとエラーが再生成される可能性があります。apache埋め込みファイルの内容を正しく使用するにはどうすればよいですか?

httpd.confエラーを引き起こす結論は次のとおりですIncludeOptional sites-enabled/*.conf.confフォルダ内の唯一のファイルは、次の内容が含まれています sites-enabledmydomain.com.conf

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
    ErrorLog /var/www/mydomain.com/error.log
    CustomLog /var/www/mydomain.com/requests.log combined
</VirtualHost>

上記の1行のインクルードディレクティブを除いて、プリインストールされたhttpd.confものと同じです。私はhttpdこのエラーが発生する前にこれをsudo yum remove httpd mod_ssl行ったので知っています。sudo yum install httpd mod_ssl専門はファイル共有サイトでご覧いただけます。httpd.confこのリンクをクリックしてください

明示的に従ったときにこの問題が発生しました。このチュートリアルの手順

インクルードファイルをコメントアウトすると、に定義されているhttp/mydomain.com静的コンテンツが正常に提供されます。問題は、上記のインクルードファイルのディレクティブで発生したようです。 /var/www/htmlDocumentRoothttpd.confVirtualHost診断を支援するために、以下のEDIT#3の3つのインクルード.confディレクティブに含まれるすべてのファイルへのリンクが含まれています。httpd.conf

編集#1

/etc/hostnamem32が提案したDefineを変更しようとしましたが、mydomain.comまだ再apache起動されておらず、systemctl status httpd.service結果は次のようになります。

[sudo_user_account@server-ip-address ~]$ sudo systemctl status httpd.service -l
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: failed (Result: exit-code) since Tue 2014-12-23 14:25:35 EST; 20s ago
  Process: 31993 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 31991 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 31991 (code=exited, status=1/FAILURE)
   Status: "Total requests: 1; Current requests/sec: 0; Current traffic:   0 B/sec"

Dec 23 14:25:35 hostname systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Dec 23 14:25:35 hostname systemd[1]: Failed to start The Apache HTTP Server.
Dec 23 14:25:35 hostname systemd[1]: Unit httpd.service entered failed state.  

編集#2

/etc/hosts私はまた、次のようにファイルの内容を変更するようにeyoung100の提案を試しましたが、まだ上記のEDIT#1で定義されているのと同じエラーが発生します。

編集#3

DerekCのリクエストに応じて実行し、以下をsudo apachectl configtest取得しました。

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e23f:49ff:feb7:2a21. Set the 'ServerName' directive globally to suppress this message
Syntax OK

また、GarethTheRedが提案したようにincludeディレクティブを確認しました。httpd.conf。 3つのインクルードディレクティブがあります。httpd.conf。各ディレクティブのフォルダ内のすべてのファイルとともに、以下にこれら3つのファイルを一覧表示しました。これらは.confランダムですhttpd。まだ何も修正していません。.conf次のリンクをクリックすると、ファイル共有サイトで各ファイルを表示できます。

Include conf.modules.d/*.confディレクトリ内の次のファイルを参照してくださいconf.modules.d00-base.conf
00-dav.conf
00-lua.conf
00-mpm.conf
00-proxy.conf
00-ssl.conf
00-systemd.conf
01-cgi.conf

IncludeOptional conf.d/*.confディレクトリ内の次のファイルを参照してくださいconf.dファイルの自動索引付け
SSL構成ファイル
ユーザーディレクトリ構成ファイル
Welcome.conf
ここでは省略したREADMEファイルもあります。

また、IncludeOptional sites-enabled/*.confガイドラインとその内容は上記のOPで詳しく説明されています。

ここに含まれているファイルがのVirtualHost設定と競合していますかmydomain.com.conf

編集#4

mydomain.com.confgarethTheRedの提案に従って、そのディレクトリに移動してconf.d再起動できるまで1行ずつコメントを付け始めました。その後、どのくらいの行を保持して再起動できるかを調べるために、行のコメントを削除し始めました。再起動できましたが、引き続き同じ警告が表示されます。 mydomain.com.confhttpdhttpdhttpdsystemctl status httpd.service -l

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e23f:49ff:feb7:2a21. Set the 'ServerName' directive globally to suppress this message

VirtualHost上記の警告が引き続き生成されても、起動を許可する構文は次のとおりですhttpd

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot /var/www/mydomain.com/public_html
</VirtualHost>  

次の行を省略する必要があることに注意してください。対応する行がある場合は、http の起動に完全な障害が発生すると警告が拡大されます。

# ErrorLog /var/www/mydomain.com/error.log
# CustomLog /var/www/mydomain.com/requests.log combined

また、実行してみるsudo journalctl -xelu httpdと、端末は次を何度も繰り返して応答しました。

-- 
-- Unit httpd.service has finished shutting down.
Dec 24 17:48:43 server-ip-address systemd[1]: Stopped The Apache HTTP Server.
-- Subject: Unit httpd.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has finished shutting down.
Dec 24 17:48:48 server-ip-address systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has begun starting up.
Dec 24 17:48:48 server-ip-address httpd[10364]: AH00558: httpd: Could not reliably d
Dec 24 17:48:48 server-ip-address systemd[1]: Started The Apache HTTP Server.
-- Subject: Unit httpd.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has finished starting up.
-- 
-- The start-up result is done.
lines 887-909/909 (END)

注:eyoung100のホストファイルを使用するか、m32のホストファイルを使用するかは、上記の結果は同じです。 この質問に答えるには、ログファイルを作成してサーバー名の警告を避けることができる必要があると思いました。 それ以外の場合は、httpdを構成する後続のステップでエラーが長続きすることが心配されます。

ベストアンサー1

apacheWebサイトのルートディレクトリに書き込めないため、ログでエラーが発生しています。ファイル権限を変更しても SELinux によってブロックされます。apacheログのみ記録でき/var/log/httpdます。最も簡単な解決策は、ウェブサイトをこのディレクトリにログインするように変更することです。 Webサイト名を含むファイル名を使用することもできます。他のログと区別するようにしてください。

ErrorLog /var/log/httpd/mydomain_com_error.log
CustomLog /var/log/httpd/mydomain_com_requests.log combined

サーバーのホスト名を設定してAH00558警告を削除するには、次のようにします。

hostnamectl set-hostname --static <FQDN of your machine>

例えば

hostnamectl set-hostname --static mydomain.com

おすすめ記事