Apache 2では、ServerNameディレクティブはグローバルにどこに設定されていますか?

Apache 2では、ServerNameディレクティブはグローバルにどこに設定されていますか?

メモ:これは私の質問に関連しています: "Apache 2.4は再ロードされません。構成に問題がありますか?」。

ローカルサイトをローカルでテストしようとしています。私が知っているのはApache 2(そしておそらくApache)にはVirtualHost

configtestとにかく、Apache 2を実行して失敗した場所を確認すると、次のエラーが発生します。私はApache 2.4.10-1を実行していますが、Apache 2.2とApache 2.4の間に私が知らない多くの変更が発生したようです。

$ sudo apache2ctl configtest
[sudo] password for shirish:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

/etc/hostsファイルは次のとおりです。

 $ cat /etc/hosts
127.0.0.1    localhost
127.0.1.1    debian mini

空のファイルも表示されます/etc/hosts.conf。認識するには、その中のデータをサーバー/etc/hostsにコピーする必要がありますか?/etc/hosts.conf

私のホスト名:

$ hostname
debian

サイトの構成ファイルは次のとおりです。

$ cat /etc/apache2/sites-available/minidebconfindia.conf
<VirtualHost mini:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/html/in2014.mini/website

    <Directory />
        Options +FollowSymLinks +Includes
        Require all granted
    </Directory>

    <Directory /var/www/html/in2014.mini/website/>
        Options +Indexes +FollowSymLinks +MultiViews +Includes
        Require all granted
    </Directory>
</VirtualHost>

私もアドレスとポートバインディングについてお読みください。しかし、いくつかの理由でよく理解されていません。この行をどのファイルに配置する必要があるのか​​、前後に何が起こるのかの例を提供/共有しません。例があればもっといいと思います。

これを行い、サーバーを再起動しましたが、まだ同じエラーが発生します。

~$ sudo apache2ctl configtest
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

Debianには、私が理解し理解する必要がある3つの設定ファイルがあるようです。

/etc/apache2$ ls *.conf
apache2.conf  ports.conf

そして

/etc/apache2/conf.d$ ls *.conf
httpd.conf

明らかに、apache2.confはグローバル構成ファイルであり、httpd.confはユーザー構成ファイルです。 ports.confもあります。 apache2.conf と ports.conf はどちらもデフォルトです。ただし、Apacheのログレベルwarndebug

私が試したもう一つのこと:

$ sudo apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
127.0.1.1:80           debian (/etc/apache2/sites-enabled/minidebconfindia.conf:1)
*:80                   127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

たぶん誰かがより多くの洞察力を持っているかもしれません。

ベストアンサー1

編集するファイル:

/etc/apache2/apache2.conf

ファイル編集コマンド:

sudo nano /etc/apache2/apache2.conf

グローバルサーバー名の場合は、ファイルの上部(仮想ホストタグの外側)に配置できます。

最初の行は次のとおりです。

ServerName myserver.mydomain.com

次に、次のコマンドを使用して構成を保存してテストします。

apachectl configtest

あなたは以下を得るべきです:

文法が決定しました

その後、サーバーを再起動し、エラーメッセージが表示されないことを確認できます。

sudo service apache2 restart

おすすめ記事