Setting up a Site Server with Jaguarby James Duncan Davidson, presenter of sesssions and tutorials at the O'Reilly Mac OS X Conference
You probably know that Mac OS X ships with a built-in Web server, and you might even know that it's of the famed Apache variety.
But did you know that almost all of the software to set up a heavyweight, full-fledged site server -- a machine that not only serves Web pages, but handles DNS and mail as well -- is already on your machine? With a little bit of tweaking, and the compilation of one piece of software, you can turn any Mac OS X machine you happen to have lying around into a first-class server. All that's needed is a little time and a roadmap -- and this article will provide you the roadmap.
What You Need
Very little is actually needed to make Mac OS X into a full-fledged site server. Here is the short list of things that you'll need for working through these instructions:
- Mac OS X 10.2 (Jaguar).
- A machine capable of running Jaguar.
- Familiarity with the Unix shell.
- A DSL, cable, or other broadband connection.
Jaguar is the latest release of Mac OS X (10.2). I've picked it because it contains the latest bits from Apple, and I want to make sure that this article stays current for as long as possible. In addition, Apple has been quite good about releasing security updates for Mac OS X, including updates for Apache, OpenSSL, OpenSSH, and many other critical pieces of software. Using the latest version of OS X ensures that you'll be able to take advantage of any updates that will come out in the future.
Configuring sendmail on Jaguar -- Sendmail is powerful, but at times appears complicated too. James Duncan Davidson helps you unravel the sendmail knot so you can configure this awesome mail server on your Mac OS X system.
You don't need a very beefy machine to run your site. The primary machine for my own domain is a Pismo series PowerBook G3 with a 400MHz processor. Why did I use a PowerBook? The answer is simple: laptops come with their own built-in UPS, in the form of their batteries. With two batteries installed, I figure I've got a runtime well in excess of 10 hours -- especially since the screen is off most of the time. Of course, my DSL modem is on an external UPS as well, so that connectivity to the net doesn't suffer when a California blackout strikes. In any case, the PowerBook was just lying there, so I used it. Any old Mac that you have around, as long as it will run Mac OS X, will work, even if it's too slow to really serve as a primary machine any more.
As far as memory and disk space goes, I successfully run my server with 192MB of RAM and a 6GB hard drive. Pretty modest by today's standards to be sure, but I've not upgraded the memory in my server because, well, after several months I haven't had to. Maybe one of these days I'll get around to buying some of that cheap memory that is out there, but it's not a priority.
The next item on the list that you need to have is some familiarity with the Unix shell in order to follow these instructions. Don't worry, I'm not going to assume that you are a rocket scientist with the shell in order to complete the steps presented in this article, but if terms such as
emacs sound alien to you, then you'll want to read a couple of other articles and get some command-line experience. Here's a series of tutorials to help you with this.
The last item on the requirement list is a broadband connection. You'll want to have an "always-on" connection to the Internet. I suggest that you get a connection with a static IP address, but you can use DynDNS.org to help people find your site if you don't have a static IP. More on this later in the article.
The Road Ahead
Here's the list of steps that we are going to take to turn your Mac OS X machine into a site server:
- Set up Name Services.
- Set up Apache for serving Web pages.
- Set up Sendmail for handling incoming and outgoing mail.
- Set up UW Imapd to let you access your mail.
Without further ado, let's get going!
First Stop: Name Services
The very first thing you need to do is determine how you, as well as other people, are going to find your site. For example, to browse this site, you simply type "www.macdevcenter.com" into your browser, and the site pops up for your viewing pleasure. Under the covers, the Domain Name System is used to translate the name that you can understand, www.macdevcenter.com, to the IP address, 126.96.36.199, that is used by the underlying software to connect to, and download content from, the site.
If you have never seen this before, it is useful to take a look at how this works. Pop open the Terminal.app (double-click on
/Applications/Utilities/Terminal) and enter in the following command:
[Titanium:~/] duncan% nslookup www.sun.com
This command will output something like the following:
Server: fraggle.speakeasy.net Address: 188.8.131.52 Name: www.sun.com Addresses: 184.108.40.206
The first two lines of data tell you the server you're making the request from, and the second two lines give you the information you're requesting. Another command you can use instead of
host, which gives you a simple one-line answer to your request. If you really want to have some fun, use the
dig command to see additional information, such as who has authority over the domain you're inquiring about.
So, the question remains: How will people get to your site? In part, this question depends on whether your Internet provider has provided you with a static or dynamic IP address.