2

How can I create a domain name for local purposes?

for example I have a local web application enviroment in http://localhost:8000 but I would like to have it in http://dev instead.

I am using Ubuntu 10.04

2
  • Used parenthesis between http because, due my low reputation was not posible to post more than one link. – juanefren Aug 2 '10 at 21:51
  • You just have to format the URLs as code like Lawrence did for you. – Felix Aug 2 '10 at 22:19
2

You should be able to use a text editor of your choosing to edit your /etc/hosts file. Add two entries that look like this:

127.0.0.1   dev
::1         dev

These hosts entries map the "dev" hostname to your machine's loopback interface (address 127.0.0.1 under IPv4, and 0:0:0:0:0:0:0:1 for IPv6). After saving, "http://dev" should behave identically to "http://localhost".

(NB: You will need superuser permissions to edit the /etc/hosts file.)

3
  • 2
    aliases are the better way: 127.0.0.1 localhost dev - this way applications that rely on the name(!) localhost will still work and http:/dev will too. The port is another issue.. – matthias krull Aug 2 '10 at 22:21
  • 1
    I do not believe having multiple entries for 127.0.0.1 affects the use of "localhost". – Lawrence Velázquez Aug 3 '10 at 1:50
  • i agree, multiple entries for 127.0.0.1 is fine – bryan Aug 4 '10 at 5:22
0

I'm running DNSMasq for this kind of thing. It has DHCP server too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.