LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-29-2013, 04:50 AM   #1
sunzeal
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Rep: Reputation: Disabled
Is it possible for sub-domain entry in /etc/hosts for virtualhosts ?


Is it possible to have sub-domains in /etc/hosts file in my local virtual machine ?

I have entry of IP example.com , but i want to work with Virtual Hosts so i tried IP test.example.com in hosts which did not work.

Earlier, i had used a dedicated machine to act as a DNS and than third machine to access domains in virtual hosts.

Is having DNS the only solution ? What are the alternatives ?
 
Old 11-29-2013, 04:54 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
DNS and hosts file just achieve the same objective in different ways. a subdomain virtual host is totally possible, it's not "interesting" per se. Sounds like you maybe aren't matching the virtualhost in Apache with a wildcard or something?
 
Old 11-29-2013, 04:58 AM   #3
sunzeal
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
DNS and hosts file just achieve the same objective in different ways. a subdomain virtual host is totally possible, it's not "interesting" per se. Sounds like you maybe aren't matching the virtualhost in Apache with a wildcard or something?
Hi

In /etc/hosts i tried : IP test.example.com entry and i tried pinging which did not work.

IP to example.com entry in /etc/hosts works just fine but when i try with sub-domain it doesn't work.

How can i get the sub-domain entry point to my localmachine so that apache than can read it for Virtual Hosts directive.
 
Old 11-29-2013, 04:59 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
well that's nothing even remotely relevant to apache then if you're not even resolving it. It should work just fine, Put the new hostname on the same line as the existing one and try that.
 
Old 11-29-2013, 05:28 AM   #5
sunzeal
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
well that's nothing even remotely relevant to apache then if you're not even resolving it. It should work just fine, Put the new hostname on the same line as the existing one and try that.
thank you so much chris, it started working now.

Strange, 2 separate entries with name and sub-domain did not work, but both in 1 entry did the job.
 
Old 11-29-2013, 05:39 AM   #6
sunzeal
LQ Newbie
 
Registered: Sep 2012
Posts: 26

Original Poster
Rep: Reputation: Disabled
figured it out, thanks

Last edited by sunzeal; 11-29-2013 at 06:16 AM. Reason: resolved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
entry in /etc/hosts zafar466 Programming 1 06-09-2008 03:51 PM
How to configure so I don't need to type domain name or FQDN for same domain hosts? lumix Linux - Newbie 1 05-22-2008 08:59 PM
Cant get entry in bind to work with domain.com instead of www.domain.com pxes351 Linux - Networking 12 05-09-2005 07:20 AM
hosts MX entry twistedpair Linux - Networking 1 01-10-2004 04:01 AM
hosts entry for a lan unit with no dns entry linxtc Linux - Networking 1 10-03-2003 09:05 AM


All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration