DNS and registrar configuration
For the purpose of this tutorial, lets assume you want to run both a QA and Production Web server.
www.qa.example.com will run from a Web server in your LAN and will be used for testing purposes. www.example.cm will run from a Web server in a well known registar's farm, and will be your public facing Production Web server. Let's assume you have registered www.example.com with Go Daddy. By default, www.example.com will point to the IP address of a Web server in Go Daddy's farm. Production Web servers should use a well known registrars farm. Running a production Web server from a computer in your house is not ideal. The upload and download speeds of an average consumer class ISP connection can't handle the bandwidth required by a production Web server. Your ISP may also require that you purchase a business class connection with a dedicated IP address if they determine you are using a Web server. It is much less expensive to rent a static IP address from a registrar.
It is okay to run a QA Web server from your home for testing purposes. Let's say you want to run www.example.com from GoDaddy's farm and www.qa.example.com from a Web server in your LAN. First you will need to establish qa.example.com in the GoDaddy control panel.
- Sign into www.godaddy.com
- Next to Domains, select the Manage button
- Select your domain name
- Next to forwarding, under subdomain select manage
- Select Add Subdomain Forwarding
- Complete the form and select Add
- Select Save
Wait about 5 minutes, and then go to the DNS zone file tab. There should be an A (host) record for qa.example.com. If not, follow these directions:
- In www.godaddy.com, select the DNS zone file tab
- Select Add Record
- Make the following selections:
- Record Type: A (Host)
- Host: qa
- Points To: The IP address of your LAN
- TTL: 1 hour
Note: It can take up to 48 hours for qa.example.com to be available on the Internet, so grab some coffee.
Hosts file and QA Web server
When first setting up a QA Web server in your LAN, if a domain name has not been registered, you will need to enter the IP address of your Web server in a Web browser to get a Web page from your Web server, such as http://192.168.0.7. On each computer in your LAN, an entry can be added to the computers HOSTS file to map the IP address of the Web server to a domain name. As an example, if we add an entry to the HOSTS file that maps IP address 192.168.0.7 to domain name example.com, we will be able to get a Web page from the Web server using the domain name of http://www.example.com. This will only allow you to view Web pages from your Web server in your LAN. You will not be able to get Web pages from your Web server when using any computer which is not part of your LAN. For this reason, modifying the HOSTS file should only be done for testing purposes.
The HOSTS file is located at C:\Windows\System32\Drivers\etc\\. Edit this file with notepad, and add the IP address and then the domain name, such as 192.168.0.7 example.com to the bottom of the file.
- In Terminal, enter nano /etc/hosts to edito the /etc/hosts file using the nano editor
- Enter a new line with the IP address and then the domain name, such as 192.168.0.7 example.com
- Press Ctrl O and then Enter to save the changes
- Press Ctrl X to exit the nano editor