I think there may be some confusion between a machine hostname and hosting websites/domains on your machine.
To set the hostname you can use the hostname
command. Something like the following should work on ubuntu. (You would also have to modify your DNS records so that mycomputer.domain.com
resolved to your IP)
sudo hostname mycomputer.domain.com
See hostname man page for more information. You will also need to make these changes in the /etc/hostname
file or else the hostname will change back when you next reboot.
To point a domain like www.something.net
to a page on your machine you would need to edit the DNS records for something.net, these records could be maintained locally on the machine itself but you would have to setup a DNS server. It is quite likely that your DNS for something.net
will be provided by the company you registered the domain with, in which case you would simply have to change which IP address www.something.net
and something.net
point to (via their website etc). Then setup a webserver to respond/serve pages for those sites.
You might find the ApacheMySQLPHP guide on the ubuntu wiki help for configuring a web server.
/etc/hosts would not really be involved unless you were making some kind of test setup/intranet system.
Hope this helps.