Reputation: 77
I need to configure two name-based virtual hosts in my Ubuntu PC. If I type the address http://mypage1
in browser, it should display my first customized html page and if I type the address http://mypage2
, it should display my second customized html page. I tried out the following:
created a file mypage1
inside sites-available
with the contents as follows:
<VirtualHost *:80>
ServerName mypage1
ServerAlias http://mypage1
DocumentRoot /var/www/mypage1/html
</VirtualHost>
created a similar file mypage2
inside sites-available
a2ensite mypage1
and a2ensite mypage2
to generate soft links inside sites-enabled.sudo /etc/init.d/apache2 restart
After doing the above steps, when I type mypage1
in firefox, I get dns_unresolved_hostname error.
Kindly help me how to resolve this problem.
Upvotes: 0
Views: 1465
Reputation: 497
DNS unresolved means exactly what it said! It could not find the DNS entries for 'servers' called mypage1 or mypage2.
Add them to you /etc/hosts file like
127.0.0.1 mypage1 mypage2
If you are successful then you will probably get a different error, then you can start looking into virtual hosts configuration
Upvotes: 2
Reputation: 86496
For one thing, you should set a NameVirtualHost for whatever IP(s) you intend to serve the files from. (If you don't, Apache will usually ignore the server name and just use whatever site is defined/included first.)
Also, make sure "mypage1" and "mypage2" are actual, valid domain names, or put them in /etc/hosts. Apache's knowing about them doesn't automatically make them known anywhere outside Apache -- especially to your machine's DNS resolver.
Upvotes: 1