I’m setting up Ubuntu for the first time and I’d like to use this as a server to host websites:
www.something.net
blah1.something.net
blah2.something.net
what do i need to set up as the hostname? and how does this need to be set up in /etc/hosts file?
thanks!
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
hostnamecommand. Something like the following should work on ubuntu. (You would also have to modify your DNS records so thatmycomputer.domain.comresolved to your IP)sudo hostname mycomputer.domain.comSee hostname man page for more information. You will also need to make these changes in the
/etc/hostnamefile or else the hostname will change back when you next reboot.To point a domain like
www.something.netto 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 forsomething.netwill be provided by the company you registered the domain with, in which case you would simply have to change which IP addresswww.something.netandsomething.netpoint 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.