i have main site on www.domain.com and have created one subdomain called demo.domain.com but when i try to access the subdomain demo.domain.com, its showing the same site as my main domain, how do i fix this? here are how i have defined the virtual hosts in my
/etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin webmaster@domain.com
DocumentRoot /var/www/domain.com/public_html
ServerName domain.com
ServerAlias www.domain.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@domain.com
DocumentRoot /var/www/demo.domain.com/public_html
ServerName demo.domain.com
ServerAlias www.demo.domain.com
</VirtualHost>
i even tried
service httpd restart
it throws
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Mon Jan 13 15:54:14 2014] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
i have added both the main domain and subdomain in the host file
[root@public_html]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
1.2.3.4 domain.com demo.domain.com
and i have created a A record for the subdomain name in my DNS manager pointing it to the my main vps IP - Address. my DNS file
demo IN A 1.2.3.4
@ IN A 1.2.3.4
www IN A 1.2.3.4
so when i access domain.com and demo.domain.com it shows the same page as of domain.com
i have created a index.html in
/var/www/demo.domain.com/public_html
[root@public_html]# cat index.html
<html>
<head>
<title>www.example.com</title>
</head>
<body>
<h1>Success: You Have Set Up a Virtual Host</h1>
</body>
</html>
so how i can fix this ? i am using centOS 6, 64 bit
when i try to access the subdomain demo.domain.com, its showing the same site as my main domain www.domain.com
As arco444 suggested.
try
cat /etc/httpd/conf/httpd.conf | grep NameVirtualHost
and comment out
#NameVirtualHost *:80
so itll become
NameVirtualHost *:80
then restart apache by entering
service httpd restart
now it should show sub-domains their respective sites/pages.