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-allhoststo
127.0.1.1 example example
127.0.0.1 localhost
104.236.247.139
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-allhostsCan 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
21 Answer
Your /etc/hosts file should look like this:
127.0.1.1 example
127.0.0.1 localhost
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-allhostsFor 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 example.com foo.com bar.com 2