How to enable test custom domain

November 25, 2019 83 views
LAMP Stack

Used this tutorial and created custom domain name for testing. But opening in browser shows page not found, only wne I use 127.0.1.1 it works. Do I have to use officially registered domain paid name? Or I just have to put it in /var/www as subfolder?

2 Answers

HI @rulet,

You can use a domain that hasn’t been registered however you’ll need to edit the host file on your local computer to actually see it.

Let me give you some explanation what a hosts file is

First of all, the hosts file is a relic of the past. In the early days of the internet, the file was used to link domain names to certain IP addresses i.e. to ‘resolve’ them. For example, the hosts file made sure that the computer knew what IP address was meant by www.ionos.com. Therefore, the hosts file used to contain a long list of these hosts and their special addresses. The influence of the term 'host’ is still noticeable today when you speak of 'hosting a website’.

This means you have actually say to your computer the domain example.com to load from the IP of your droplet. That way you’ll be able to load the content of your website without even having a registered domain.

How to change the hosts file in Windows XP, 7, 8, and 10

  • Find the entry 'Editor’ in the start menu and right-click on it. Select 'Run as an administrator’.
  • In the editor, go to the menu item 'Open’ which you’ll find under 'File’.
  • Open the 'hosts’ file in Windows Explorer using the path C:\Windows\ System32\drivers\etc\hosts.
  • You can now edit the hosts file.

How to change the hosts file on your Mac

  • Select the tab 'Go to’ in the upper start bar and click on 'Go to folder’.
  • In the new dialog box, enter the following file path /private/etc/hosts. Then click on 'Open’.
  • The folder containing the 'hosts’ file will then open. Double-click on it to open the file’s text editing.

How to change the hosts file in Linux/Ubuntu

  • Depending on which version of the operating system you have as well as your personal choice, you will have one or more of the following default terminal programs installed: Unity, KDE, Xfce, LXDE, GNOME Shell, MATE.
  • Open the corresponding editor (usually via 'Applications’ > 'Accessories’ > 'Terminal’).
  • Enter the following command: sudo nano /etc/hosts. The sudo prefix gives you the necessary root rights. The hosts file is a system file and is especially protected in Ubuntu.
  • You can then edit the hosts file with your text editor or terminal.

Regards,
KDSys

Have another answer? Share your knowledge.