How to assign a host name to a web server?

I use lighttpd as my web server.

I am currently accessing it using the IP address:

http://192.168.0.1 

I want to access it as

 http://myhostname.com 

I would use it only on the local network, not on the Internet.

I do not know how to do that. I googled, but don’t know which keywords to use.

+4
source share
3 answers

Place the following line in the /etc/hosts :

 192.168.0.1 myhostname.com 

For example, using the following command:

 $ sudo echo -e '192.168.0.1\tmyhostname.com' >> /etc/hosts 
+6
source

you can add the rule to your hosts file: C: \ Windows \ System32 \ drivers \ etc \ hosts

add a rule like

 192.168.0.1 myhostname.com 

On Windows, you cannot do this with wildcards, so for all subdomains you need to add a rule

+2
source

Locate the hosts file on your local computer, and then add the following line:

 192.168.0.1 www.somedomain.com 
+1
source

Source: https://habr.com/ru/post/1339629/


All Articles