Friday, June 15, 2007

Dynamic DNS, Apache, and Windows

Overview

Instead of paying for web hosting, you can run your own web server on your own cable or DSL line on your home computer. Since many ISPs do not offer static IP addresses or charge extra, you can setup dynamic DNS through DynDNS to achieve the same result. You can then give your friends or anyone else the hostname and they should always be able to access your website.

Most people use Windows for an operating system but that doesn't mean you cannot run an industrial strength webserver, Apache. Apache is the most installed and popular web server and there is a lot of help out there if you get stuck.

Once you install your web server, you can host your own web site, host your MP3 files, allow friends and co-workers to view documents, share pictures, and plenty of other things.
Dynamic DNS and Custom DNS

DynDNS offers two flavors of dynamic DNS. One is Dynamic DNS (clever name) and the other is Custom DNS. Dynamic DNS allows you have a hostname like yourname.dyndns.org always point to your IP address. Custom DNS allows you to setup a domain, like www.yourname.com to point to your IP address. Custom DNS is a paid service and Dynamic DNS is free. Setup is pretty easy and you can use our Custom DNS How-To or our Dynamic DNS How-To.
Web Server: Apache

Once dynamic DNS is setup, we know the hostname of our web site. Where we use yourhost.dyndns.org, replace that with the actual host you created.

Installing the server
Go to http://httpd.apache.org/download.cgi and download the latest version of Apache using the "Win32 Binary (MSI Installer)" link.
Accept the agreement and use the default location for installation.
Once you reach the screen asking for your server information, enter the information as follows:

Network Domain (e.g somenet.com): dyndns.org

Server Name (e.g. www.somenet.com): yourhost.dyndns.org

Administrator's Email Address (e.g. webmaster@somenet.com): youremailaddress
At the bottom, select for All Users and then click on Next.
Complete the installation wizard using the "Typical installation" setting.
When it's done, open your web browser and go to http://localhost/. If the page you see reads, "If you can see this, it means that the installation of the Apache web server software on this system was successful," you installed Apache.

Storing files in the right place

Let's say you have a slew of pictures from your vacation and you want to share them on your shiny new web server. I store my pictures in C:\RecentPics so I'll use that in this sample.

Configuration

Using a plain text editor like Notepad, open the C:\Program Files\Apache Group\Apache2\conf\httpd.conf file. This is Apache's configuration file. Don't be alarmed. It looks worse than it is and we are only going to change a couple things and leave the rest as their defaults.

In this httpd.conf file, comment out the line that starts with DocumentRoot and add another with your directory, like this:
#DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
DocumentRoot "C:/RecentPics"

Then, comment out the line that starts with and add another with the directory you want to share:
#


Last, about 20 lines below that line, then modify that to read (this allows file listing):
#AllowOverride None
AllowOverride All

When you're done, save httpd.conf.

Start it up

Click on the Apache icon in your taskbar and choose "Restart." If Apache restarts successfully, you edited your the file correctly. Visit http://localhost/ in your web browser and you should see a list of your pictures!
Troubleshooting:

If you can not connect to your server using the addresses above, you need to check the following:
Make sure yourhost.dyndns.org is pointing to the external IP, the one your ISP has assigned you. If not, log in and update it. You won't be able to access the host from inside your network if you are behind a router.
Check with your router manufacturer to see if you are forwarding port 80 properly
Make sure no firewall is blocking access
Contact your ISP to see if they are blocking port 80. If they are, try our HTTP redirection services WebHop and MyWebHop

No comments: