Subdomain and server IP returns the first domain configured in httpd.conf

Dear,

I have tried to create subdomain by adding dns and edit the httpd.conf file in /etc/httpd/conf. But all the subdomain returns the first domain that be added in httpd.conf. The problem is happen with the IP of server, when I use the server IP as website address, I get the first domain that configured in httpd.conf.

Please tell me what I need to do in this case.

Thank you,

Hmm, are you using Virtualmin? If so, I might suggest using it to add domains to your server… it’ll handle setting up Apache, your DNS, and so forth.

The problem could be a few things – of note is that if you manually add a record into the httpd.conf file, any IP address you use in a VirtualHost block would in most cases need an associated “NameVirtualHost” record before it.

That’s normally done for you when using Virtualmin, but when manually adding records, adding in a NameVirtualHost line might just solve that for you.

-Eric

I’m not actually seeing an entry for “softwares.free1m.com” in your httpd.conf file.

There would need to be a VirtualHost block in there that contained a ServerName or ServerAlias that included the name “softwares.free1m.com”. Otherwise, it would indeed show the first domain found in the httpd.conf file.

That’s actually an Apache feature – if there’s no entry for a given domain in the httpd.conf, it’ll always give out the first domain listed in it. So you’d simply need to either add a new VirtualHost block, or add softwares.free1m.com to an existing block.

-Eric

Yes, I am using virtualmin. Actually, I only setup DNS by adding CNAME for sub.domain.com to domain.com. The problem happened before I edit the httpd.conf file. I dont know why my system return the website of the first domain configured in the httpd.conf.

If DNS of subdomain specify to the outside of server (eg: CNAME for ghs.google.com), everything works properly.

Please see the generated httpd.conf by admin in the attachment.

Everytime I go softwares.free1m.com, I got the content of the first domain.
Thanks,