4

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!

user1337645
  • 473
  • 8
  • 16
  • The hostname should be set to the machine's host name. If that's "www.something.net", then set it to that. You can call the machine whatever you want. If you want to call it "jack.something.net", do that. It has no effect on its ability to host web sites. `/etc/hosts` doesn't much matter either. – David Schwartz May 31 '12 at 00:49
  • 1
    this belongs on superuser/serverfault – Daniel A. White May 31 '12 at 01:14

1 Answers1

3

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.

Andrew
  • 2,540
  • 1
  • 16
  • 9