Setting up your own domain name and server

Writer(s): 
Paul Daniels

In the May Wired column, Malcolm walked you though the steps of obtaining a domain name and setting up a website with a hosting company. What about those of us who want to host our own server? This month's column explains how to set up your own domain name on your own computer.

Basics

Hosting your own website may sound like a great way to save money. There are, of course, costs involved with a computer, an Internet connection, and electricity needed to power your computer 24 hours a day. If you are fortunate enough to already have these three resources available at your school, you can have a server up and running in minutes with very little cost involved.

Benefits

There are many very good reasons for running your own server. The satisfaction as well as the learning process of setting up your own machine can be enormous. In addition, you do not have to pay a monthly fee to a web hosting company, which can average US$300 per year, and there is the freedom of configuring the server any way you desire. You have the flexibility to install new software and try out all types of scripts. Finally, you don't have to worry about disk space limitations. You can simply add a new hard drive if you run out of space. If you are interested in serving heaps of large video or sound files, you may want to seriously consider running your own server due to disk space limitations with commercial hosting companies. In addition, accessing these large files on a local network will be considerably faster than over the Internet.

Drawbacks

It can certainly be a hair-raising experience running your own server, especially if you are going to be managing data for other teachers or staff at the workplace. You can imagine how your co-workers would feel if their files were deleted from the server after spending months creating them. I would highly recommend that you set up an automated backup and restore system for all web content and scripts stored on your server and that you recommend users to keep a backup of their own content on their personal computer. Another concern is the extra heat that a continuously operating server produces.

Hardware

Just about any computer can be a server. If you are serving webpages to a few hundred students or teachers, you will not need anything too powerful. My web server can easily serve 5MB video and audio files to a class of 30 students with a 1 GHz Pentium processor and 512 MB of memory. A commercial server will have a better cooling fan (since it will be running continuously), more memory, and perhaps a SCSI or RAID hard drive for better performance.

Setup

Macintosh

Apple Macintosh OS X ships complete with a very powerful web server package called Apache. This is the same software that large companies use to serve webpages to millions of users. The easiest way to start the Apache web service is via your Mac OS X system preferences. From your Apple Menu, select System Preferences, and then Sharing. A Sharing preference panel will pop up. Locate the Web Sharing label and click the start button to start the Apache web server. An excellent resource for Apple administrators can be found at macdevcenter.com/pub/a/mac/2001/12/07/apache.html.

Windows

Windows NT, 2000, and XP Professional ship with an integrated web server called Internet Information Server or IIS. IIS can be installed by opening the Control Panel and choosing Add/Remove Software and then Add/Remove Windows Components. Microsoft's IIS and Apache are quite different and both have advantages and disadvantages. To better judge which to use, you may want to read www.serverwatch.com/tutorials/article.php/3074841. Consider running IIS if you plan to serve data over the web via an Access database or are interested in running asp scripts. If you are not interested in either of these or prefer using open-source software, I would recommend downloading a package such as AppServ www.appservnetwork.com which will install the Apache web server and other useful applications such as the MySQL database server and a PHP web-based script engine. After downloading, double-click on the saved .exe file to install. You will need to choose a username and password.

Linux or UNIX

Setting up a web server on a Linux or UNIX machine goes well beyond the scope of this column. That being said, most popular distributions such as Red Hat, SuSE, or BSD will automatically install the apache web server if you choose the server rather than the workstation install. To check if the web server is running, just type in this command: "/path/to/httpd status". For example, Red Hat 9.X users would open the command prompt and type in "etc/rc.d/init.d/httpd status". You can also check if your web server is running by opening your web browser and typing in the address <http://127.0.0.1>.

Domain Name Server

Once you have your domain name registered (see May 2004 TLT Wired Column) or assigned by your network administrator, and you have your web server up and running, you will need to point your domain name to the IP address of your server. This is done through a domain name server or DNS server. If your school assigned you a domain name, they most likely have already configured their domain name server to point at the domain name they assigned you. If you want to choose your own domain name, you can register it yourself and point the domain name to your computer's IP address using a DNS server. While it is possible to set up your own domain name server, it is somewhat impractical since you really need two of them. Check with your network administrator if it is possible to add a domain record to their DNS server. If not, there are several inexpensive solutions for DNS hosting. There is a free service with soa.granitecanyon.com, although I have not found it to be very user friendly or reliable. I recommend using a service from dns.widge.net that runs US$8 per year. Another is www.zoneedit.com. Once you register your domain with a DNS hosting service, you will need to enter your computer's IP address and your domain name on the DNS provider's web-based setup page.

Virtual Hosting

Virtual Hosting simply refers to the process of having several domain names or several different websites running on a single computer with a single IP address. It is very useful if you share a web server with others or want to run several websites with different domain names on a single computer. Let's say, for example, you have three separate websites: jalt.org, jalt-publications.org, and jaltcall.org. Virtual hosting will allow you to serve these three websites using a single IP address on one computer. If you installed Apache web as described earlier, search your hard drive for a file named httpd.conf. Once you locate this file, open it with a text editor and search within the text for NameVirtualHost. You should find this line: #NameVirtualHost *:80

You will need to delete the # sign and replace the * with your computer's IP address. Keep the trailing ":80" as this refers to the port number that your web server is running on. Next, scroll down in the same text file and you will find the following text or something similar:

#<VirtualHost *:80> # ServerAdmin webmaster@my-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName my-host.example.com
# ErrorLog logs/my-host.example.com-error_log
# CustomLog logs/my-host.example.com-access_log common
#</VirtualHost>

Edit at least the first, third, and fourth lines. In the first line, replace the * with your computer's IP address. In the third line, provide the path to your DocumentRoot. This is the folder where you put all of your files you want to serve. Finally, in the fourth line, replace ServerName with your domain name. You must also delete the # signs. Any line with # is ignored by Apache. Below is an example of the httpd.conf file on a Windows machine:

NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot c:\appserv\www\jaltcall
ServerName jaltcall.org
</VirtualHost>

You will then need to create the folder that you named as the DocumentRoot, which in the above example is named jaltcall. Finally, all of the files that will be served from jaltcall will go into that directory. If you used Appserv to install Apache on a Windows machine, the document root will be c:\appserv\www\your-virtual-host-directory. For OS X users, it might be something like: /Library/WebServer/Documents/your-virtual-host-directory.

You can create a <VirtualHost> block for each unique host that you would like to run on your computer. If using Microsoft's IIS, you can refer to www.dyndns.org/support/kb/iisvhosts.html. For apache users, more information can be found at httpd.apache.org/docs/configuring.html.