So, you're ready to launch your site. You've got it all set up on the production server and all you need to do is log in to your domain host and point the domain at your new server and hope everything is working. Hope everything is working? Yes, that seems to be how most developers think. I've encountered several people who use this method for launching a site.
Fear not friends there is a simple solution that will allow you to fully test your site on the live server before switching the DNS to make it live to the rest of the world.
All you have to do to make this dream a reality is point your local hosts file to the ip of the new server. Then when you go to the url in your web browser the hosts file will override everything and send you to the new server. This guide is broken in to 3 sections: Mac, Windows, and Linux.
Before you get started you should at least have a basic understanding of DNS and how it works. At the VERY least you need to understand A records and how they work. If you don't please don't ask me just google "how dns works" or something to that effect and do some reading on your own.
Mac OS X
- Open terminal (Applications > Utilities > Terminal)
- type: sudo edit /private/etc/hosts
- Enter your password
- Edit the hosts file. (see details below)
- Save and close the editor
Linux
- Open terminal
- type: sudo nano /etc/hosts
- Enter your password
- Edit the hosts file. (see details below)
- Save and close the editor
Windows
- Open a command prompt (Start > run > "cmd")
- type: notepad C:\windows\system32\drivers\etc\hosts
- Edit the hosts file. (see details below)
- Save and close the editor
Edit host file
This part is basically the same for all 3 system. The hosts file is extremely simple. It is just an ip address and a domain name separated by a space or tab
You should have something like this in the file (at the very least) this is connecting the loop back ip to the localhost host name.
127.0.0.1 localhost
You can associate any domain you want to any IP address and your computer will listen to your host file first before the outside world. For example if you wanted google.com to take you to my site you'd do the following.
74.84.131.77 google.com
If my server was set up to understand requests for google.com you would see my site. Instead you'll see our site not found page.
Conclusion
Once you've completed these steps you should be able to go to your web browser and enter the old site domain and have it pointed (just on your computer) to the new server. This will allow you to fully test the site before updating the domain / dns settings for the rest of the world to see.