The following Apache HTTPD configuration has been set up to create a virtual host available at www.example.com and www2.example.com:

<VirtualHost *:80>
    ServerName www.example.com
    ServerName www2.example.com
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/
    <Directory /srv/www/>
        Require all granted
    </Directory>
</VirtualHost>

Even though Apache HTTPD correctly processed the configuration file, requests to both names are not handled correctly. What should be changed in order to ensure correct operations?

A. The configuration must be split into two VirtualHost sections since each virtual host may only have one name.
B. The port mentioned in opening VirtualHost tag has to be appended to the ServerName declaration's values.
C. Both virtual host names have to be placed as comma separated values in one ServerName declaration.
D. Both virtual host names have to be mentioned in the opening VirtualHost tag.
E. Only one Server name declaration may exist, but additional names can be declared in ServerAlias options.

题解

选项「E」是正确答案。可以使用「ServerAlias」来定义多个服务器别名,可以在同一个「ServerAlias」中使用空格隔开多个别名,也可以使用多个「ServerAlias」来定义。