仮想ホストを正しく設定する方法

仮想ホストを正しく設定する方法

私が行くとき参考文献正しいDocumentRoot( /var/www/example/web)を取得しましたが、例.fr、デフォルトの DocumentRoot( /var/www/) が提供されます。

すでにいろいろ試しましたが、何も効果がありませんでした。

/etc/hosts : 
51.254.122.31   example.fr


/etc/apache2/sites-enabled/example.fr.conf :

<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName example.fr
        ServerAlias www.example.fr
        DocumentRoot /var/www/example/web/
        DirectoryIndex app.php
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

何を間違えたのか分かりますか?

答え1

おそらくNameVirtualHostディレクティブを忘れたのでしょう。 で設定された仮想ホストを確認することもできますapachectl -S

関連情報