How to assign hostname to the web server?

Mahendra Liya picture Mahendra Liya · Feb 14, 2011 · Viewed 8.3k times · Source

I am using lighttpd as my webserver.

Currently I am accessing it using the IP address as :

http://192.168.0.1

I want to access it as

http://myhostname.com

I would be using it in the local network only, and not the internet.

I don't know how to do this. I googled, but don't know the exact keywords to use.

Answer

Yasir Arsanukaev picture Yasir Arsanukaev · Feb 14, 2011

Put the following line to the file /etc/hosts:

192.168.0.1              myhostname.com

For instance, using the following command:

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