For developers who usually work on web-based applications, they must be familiar with localhost, right? yes, localhost is the usual domain nameserver and is the default used when we run the webserver on our personal computers. But, did you know that we can customize the nameservers so that they are not only localhost ?. In Linux we can easily customize it. Therefore, here’s how to create your own local domain on Linux:
Step 1 – Open the /etc/hosts file with your favorite editor
vim /etc/hosts
Step 2 – Create a nameserver with a .local domain
Then we can add the .local
nameserver to the /etc/hosts file under the line 127.0.0.1 localhost
, for example like this
127.0.0.1 localhost 127.0.0.1 lukems.local 127.0.0.1 customName.local
if you ask why should a .local
domain? The answer is because the .local
domain is a special domain name reserved by the Internet Engineering Task Force (IETF) so that it cannot be installed as a top-level domain in DNS on the internet.
Then what if we want to create our own local domain without using .local? As far as I know, you can, as long as the local domain that you created is not on the top-level domain list. To check the list you can visit the List of Internet top-level Domains .
Step 3 – Use a domain that has been created on your webserver
After you create your own domain, you can immediately use it on the webserver you are using. For example, on the Nginx webserver, you just need to add your domain to the server_name
section in the Nginx configuration file like this:
server { listen 80; server_name lukems.local;
Step 4 – Access your custom domain via a browser
When finished, you can immediately access it through your respective browsers, for example like this:
Yes, that’s how to create your own local domain on Linux that I can share. Hopefully this information can be useful for all of us. Thanks: lol:
SOURCE : Wikipedia