[Novalug] setting up multiple "localhosts" with different names

Jeff Stoner leapfrog at freeshell.org
Thu Apr 8 13:24:00 EDT 2010


On Thu, 8 Apr 2010, Bonnie Dalzell wrote:

> <quote>
> you will not be successful when using "http://localhost/dogarchive"
> as then some cookies won't work, you need to use a hostname that contains
> at least two decimals such as www.test.net.
> <end quote>

Decimals? I thought they were periods. Oh well, you say tomato  while I 
say tomato.  ;-)

> Then the instructions tell how to do this for Windoze.
>
> How would I make a localhost hostname with two decimals under linux?

Launch a terminal.

if USER_PREF = "I like vi"
   sudo vi /etc/hosts
else if USER_PREF = "I like nano"
   sudo nano /etc/hosts
else if USER_PREF = "I like gedit"
   sudo gedit /etc/hosts
endif

The format of the file is:
<ip address> <hostname 1> <hostname 2> <hostname 3>

Each IP address can have as many hostnames associated with it as you like. 
Find the 127.0.0.1 ip address and add a desired FQDN after it, like:

127.0.0.1 localhost www.razmataz.com www.ickle.com

Do not remove the 'localhost' hostname or Bad Things may happen.

A convention that has been brewing is to use .local for situations like 
this. So consider using something like www.dogthingy.local for the FQDN.


> Can I have several different localhosts? (like one in the user directory
> and the one that is under /var/www and the one with the two decimals
> in the name?

You're probably thinking of virtual hosts. Yes, you can point different 
virtual hosts to different locations on your file system, each using 
different names. If you're looking at the Apache docs, you would want to 
set up named-based virtual hosts, not ip-based (but, in truth, you can use 
either - it's just depends on how much effort you want to put into setting 
it up.)


*FQDN = Fully qualified domain name. A computer's name is comprised of at 
least 2 parts, the hostname and the domain name. All computers show 
have a hostname while a domain name is optional. For example, 
www.yahoo.com can be broken into www = hostname and yahoo.com = domain. 
Many times, people use hostname when they mean FQDN. Depending on the 
situation, it can cause a lot of confusion or be harmless.

  --Jeff

"You cannot unsay a cruel word." - Unknown




More information about the Novalug mailing list