My home ADSL web server

The server that brought you this page is sitting in my front room.
.

Background (the boring bit)

Server Type a URL or click a link to load any web page (such as this one) onto your very own PC. We take it for granted, but it is very easy to forget that when you typed the URL or clicked the link, another computer somewhere out there on the internet received your request and had to do some work to send you all of the text and pictures in return.

Many people know that many basic ISP accounts offer basic web hosting, that is you can use some space on the ISPs servers and host your own basic website. But what if you wanted more...

At times I can be a megalomaniac and demand things "my way". Back in the slow old modem days having an ISPs webspace through a redirecting domain was good enough. But a friend of mine bought some dedicated webspace from a web hosting company some time ago. Unlike ISPs, web hosting companies are dedicated to hosting websites and typically have more professional features. Features like a domain name linking directly to the pages, hundreds of megabytes of storage, CGI, PHP, MySQL and loads of other features that he used, which I could only dream about.

Even this may not satisfy the ultimate megalomaniac, since you're still using somebody else's computer set up by somebody else. You could have your very own computer set up by you easily to perform web serving, but connecting it to the whole internet 24 hours a day would have cost you megabucks... until now.

The broadband revolution brings high speed connections to the home, but more importantly the connection is "always-on" meaning you can have them open 24/7 without any cost penalty or without making any phone line engaged. You've now got that full time connection to the internet, and a small number of people (including myself) are literally taking webhosting into their own hands.

Before we describe what we need for a server, lets describe two essential things that we need for our full-time internet connection. You need those whether you want to set up a server, or not.

Modem on top of server

ADSL Modem/Router

Whether you want to serve something to the internet, or even if you just want to surf, you need something to connect your small PC to the big net out there. The modem/router here is the Conexant AMX-CA61E which was cheap at the time and is simple, but does the job. It is Ethernet based, which is better performing and platform independent. This particular one has a USB socket as well, but I don't use it.

ISP

You also need an ISP which can provide an ADSL connection for you. The ISP I chose was Eclipse which doesn't have that many frills, but a very good price and they seem to be very reliable.

Eclipse also offer a static IP option, this is very important for home webhosting to work properly, if not at all. Every machine on the internet has an IP address (often called IP) and almost all domestic ISP accounts are arranged so every time you connect your PC gets a different IP address every time. Normally this is not a problem but your server has to be reachable anytime and if it moves IP address nobody can find it easily; imagine if your local supermarket moved location every week!

So that's what you need for your ADSL, the static IP being essential for your server.

The PC

Back of server The PC is secondhand, given to me by a friend of a friend. It is known to have been made sometime around 1998 or so. The current setup is...

Look at the above spec; stone age, isn't it? It would just about be enough for a plain Windows 98 installation, but it would be crazy to buy any Windows software today and expect it to run on that thing. If that wasn't bad enough, this is actually an "upgrade"; the webserver originally ran on a lowly Escom 90MHz.

So how is it possible to use a virtually obsolete PC as a web server? Scroll down to the Software section to find out how.

Domain

So you have a static IP address and anyone can reach your server using something like http://123.45.67.89/ but how many webpages do you access by numbers like that? The fashion is to go all the way and get yourself a .com (or in my case a .co.uk) domain name. Yes it does cost, but as I said it's fashionable! More importantly, if you ever change ISP in the future you keep your domain and thus not lose contact with anyone!

One cheap .co.uk source is Easily which sets you back just ten pounds per two years per domain.

Many domains simply redirect both web and e-mail to another site, so one could set it up to redirect to that static IP number. But with a home web server, as with any web server, you really need a domain which you can alter at least the A record with, in other words those typing that domain into their web browser will get directly to your server without redirection. If your domain provider can't do that you may be able to transfer the DNS servers elsewhere but keep the domain with your provider. In my case, my domain is owned by Easily but the DNS servers are transferred to ZoneEdit. ZoneEdit allow up to five domains to be managed for free and allow the option of redirection as well, just in case things aren't ready.

Linux

The main operating system of the server is Linux. Linux is an operating system based on UNIX and is a slowly increasing threat to Microsoft's dominance. Many people say that Linux may not yet be ready for the desktop user but thanks to environments like KDE and projects like OpenOffice.org I personally think it's more than ready to sink the Windows boat. But many also say that Linux has long been the best OS for server use. It is rock-stable, secure, versatile and give better performance on an installed system than any other. It is this ability to squeeze more performance that is a small part of what makes it able to run on less capable PCs.

Linux is available in hundreds of various "distros". A distro is a set of CDs put together by someone or a company which will install Linux on a PC along with several other utilities to make it anything from a desktop users tool to a powerful server. Until recently I used RedHat 7.3, but have now switched to Gentoo Linux for easy maintenance and upgrading.

One of the best advantages Linux (or indeed any UNIX clone) has over a Windows server is it does not need to run a graphical windowing interface (those nice pretty windows, menus and mouse pointers you see). All those pretty graphics take up many tens of megabytes of RAM and hundreds of megabytes of hard drive storage, and that's just to present that plain desktop after you switch on, before you install and run additional programs!

All a server does is listen out for a file request, and it sends that file out to whoever asked for it, no pretty graphics needed. In fact, many Internet servers run "headless" meaning they have no monitor, keyboard or mouse attached. They don't need them. Once setup a well-kept server needs hardly any maintenance at all, no need for a monitor or keyboard, so why bother with them? No need for fancy graphics and thus no need for those megabytes of RAM and storage is a bigger part of what makes it able to run on less capable PCs.

When you really do want to make adjustments to a web server that has no monitor or keyboard, how do you do it? If you've ever used your ISPs webspace, you would have used an FTP program to copy your HTML files to their server, which in most cases would be headless. A server will have a network cable sticking out, and the desktop PC which you use daily can connect to it in various ways and thus you can then take control using that PC's monitor and keyboard. These days you never have to sit in front of the very PC you want to control, many utilities can remote control a PC over a network. Just be very careful that the remote control works before you unplug that monitor and keyboard, or you could lock yourself out!

OpenSSH

FTP is enough to copy and manipulate files, but you may need to take direct control of the server itself from time to time. UNIX and their clones used telnet for some time, your headless PC would run a telnet server, enabling other computer users to control it by using a telnet client which acts as the remote control. Telnet is still around, but not recommended due to security concerns.

Nowadays SSH (Secure SHell) is the standard, it's like telnet except it has better security features and encrypts the keystrokes and texts going back and forth so nobody can listen in. On Linux there is OpenSSH, simply by running a SSH server on the server I can take control of it anytime using the SSH client on the PC I use everyday. There's even a SSH client for Windows.

Apache

So that's the operating system and the remote control taken care of, but one still needs a web server program. This is the program that sits there, armed with all the HTML files, listening on the wire for a distant computer running a web browser to say "Hey, can I have this file please?" and then fetching that file to squirt back to that distant computer. Potentially a very simple job but the facilities of sophisticated web serving software can be surprising.

The web server running here is Apache which is officially the most popular web server in the world.

PHP

Plain ISP webspace can be kind of boring, the same text and pictures being returned again and again; with fiddly maintenance. Server side scripting is one of many facilities that separate the lame ISP webspace from the real websites. For those not in the know, server side scripting means pages aren't just text and tags and things, little (or even big) programs can be embedded which can read things like feedback forms and cookies and literally printf out HTML results within the page itself.

PHP is the best server-side scripting language out there. Here's an example of a very simple server-side script; you won't see it if you view the source but this webpage has the following code stuck in the middle of the usual HTML....

<?php
    print("This <b>PHP</b> script says now is " . date("l jS F Y, G:i:s"));
?>

...just below this line, which causes the following to happen...

This PHP script says now is Monday 6th February 2012, 16:55:25

...a very simple print statement, the date() function after it returns the current date and time providing a quick demonstration on how a webpage can change. Refresh this page a few times and watch the time update on each refresh!

The main use of PHP in these pages is to provide common header banners and the footer badges you see at the bottom of pages. Also the index and links pages build the tables by declaring functions that print out each row and calling the functions with the table elements; this means I don't have to repeat those <tr><td align="right" width="35%"> tags again and again to build those tables. I just write that once in the function and by changing that single function I can change the whole table layout.

PHP can also act on HTML forms and construct images. On this website, these facilities are used on the feedback form and the index page's counter.

MySQL

Even with PHP functions set up to simplify the layout, updating data for webpages may still involving loading the whole file into an editor. The bits of data would be buried somewhere deep in a big source file. The fashionable way around this is to "separate the data from the layout" as they say, by using a database. The database here is MySQL which is free and again one of the most popular free database systems in the world.

The links page is one of the two here that is MySQL powered. All the links there are not held in the links.php file! They are held in a separate database; essentially a table with several entries. Each entry has a category, the link name, the link URL and a description of the link. The PHP code in the links.php file firstly asks MySQL to recall the database in alphabetical order by category, then alphabetical order by link name. It then goes into a loop which initially fetches the first entry from the database, prints the category only if it different from the last one, then prints the link and description; all this with the correct table tags around to lay it out nice. Then the loop repeats with the next database entry, and so on until all of the entries are accounted for.

If I wanted to add a link to that page I need not touch the PHP code at all. All I need do is connect to MySQL, select that database and issue a single INSERT statement with all the information. The link is then added, automatically sorted in with the rest! Likewise if I wanted to change the layout, I just need to modify the PHP code without having to touch the database. This is what is meant by "separating the data from the layout".


Valid XHTML 1.0! Valid CSS! Viewable with any browser .