2

I am attempting to migrate a website to a ubuntu server but would like to test it first

On windows I have changed my host file to point to the server, so the browser is opening the "new" site. In my terminal , in Ubuntu I have changed the following

127.0.1.1 example example
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

to

127.0.1.1 example example
127.0.0.1 localhost
104.236.247.139 www.example.com
104.236.247.139 example.com


# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Can I confirm that this is correct? I seem to be running into issues with finding http image urls etc, and before trying to debug I want to make the hosts file is correctly set.

Thanks

Adrian
  • 243
  • 1
    You should probably have 104.236.247.139 www.example.com example.com (i.e., one entry per IP with multiple hostnames separated by space). – muru Mar 04 '15 at 11:34
  • Please confirm, that your /etc/hosts doesn't contain Windows line endings (CR-LF). You can check with file /etc/hosts or echo "I found $(tr -cd '\r' < /etc/hosts | wc -c) carriage return characters.". – David Foerster Mar 04 '15 at 12:33

1 Answers1

3

Your /etc/hosts file should look like this:

127.0.1.1 example
127.0.0.1 localhost
104.236.247.139 www.example.com example.com


# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

For 127.0.1.1 you have put two same hostnames whereas just one will do. For the IP 104.236.247.139 you have used two different lines to express hostname and alias but you should put the hostname and aliases all in a single line separated by whitespaces, for example:

<IP_Address> <hostname> <alias_1> <alias_2> <alias_3>
104.236.247.139 www.example.com example.com foo.com bar.com
heemayl
  • 91,753