I'm migrating to a new server and would like to test before redelegating the domain over. I have some familiarity with setting up apache virtual hosts, but limited knowledge.

How can I go about setting this up? My server already has a domain delegated to the server, and the IP by default has been setup to point to that.

I've been told I can just add an entry to /etc/hosts/ which I haven't been able to understand what I can add in there to make this work.

Any pointers would be greatly appreciated!

  • So you want to test the deployment before making the DNS entry? Jul 9 '12 at 21:09
  • @Somantra, yes exactly. Jul 9 '12 at 21:10
  • 1
    +1 pun-points for Any Pointers Jul 9 '12 at 21:22
  • What do you mean by "domain delegated to the server"? Do you mean there's an A record that's pointing to the server's IP?
    – gravyface
    Jul 9 '12 at 21:48
  • Yes, thats right. Jul 10 '12 at 6:38

Here is a more detailed tutorial on creating hosts file entries.

The short answer is to make an entry in the file (c:\windows\system32\drivers\etc\hosts) that follows the pattern of IP [tab] Host(s): www.myserver.com myserver.com

On a Mac or Linux desktop, this file is at /etc/hosts.

This should be done on the client machine from which you will test the new server. Once you have put it into production and your new DNS records have propagated, you can safely remove the entry.

  • So I should be editing this /etc/hosts on my own computer and merely point it to the IP address of the server? I hadn't thought of that! I don't think I have conveyed though properly if I load up the IP of the server that it loads up an existing site I have on the same server. How can I control what web directory loads up by default when I try to connect to the IP? Jul 10 '12 at 6:40
  • @cosmicbdog,That would be the VirtualHost directive, see here: httpd.apache.org/docs/2.0/mod/core.html#virtualhost Contains directives that apply only to a specific hostname or IP address Jul 11 '12 at 19:16

The simplest solution, in my mind, would be to create a dns entry such as www-test.domain.com and point it to your new ip. In httpd.conf, add

ServerAlias www-test.domain.com

to your virtualhost config. reload named and httpd and point your browser to www-test.domain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.