I installed Apache httpd on CentOS 7 by yum. httpd is installed under /etc/httpd with tree
/etc/httpd
|-- conf/
|-- conf.d/
|-- conf.module.d/
|-- ...
Everything is default, now I want to try virtual host by adding a config file /etc/httpd/conf.d/test.conf :
<VirtualHost *:80>
DocumentRoot /www/test
ServerName www.example.com
ServerAlias example.com
</VirtualHost>
and an html file /www/text/index.html
<!DOCTYPE html>
<html>
<body>
<p> test </p>
</body>
</html>
But www.example.com in my browser still direct to the default page.
Then I tried a different directory other than /www/test after reading some articles (I also added an html file /var/www/test/index.html):
<VirtualHost *:80>
DocumentRoot /var/www/test
ServerName www.example.com
ServerAlias example.com
</VirtualHost>
This time it works! www.example.com in my browser does show the right page.
So obviously the problem is the directory /www, but why does httpd fail on /www while succeeding on /var/www? What's the difference? By the way, I have granted permission on /www to user apache