Host your own website from home, for fun and profit.
Thanks to iiNet's recent installation of a DSLAM at my telephone exchange, my home ADSL connection is now running free of Telstra's ADSL hardware. Instead of being limited to 1.5Mb/s, I can now get the full 8Mb/s that my modem and phone line can handle. My upload speed has improved too, from a poor 256kb/s to an impressive 1Mb/s, so I can now push content out almost as quickly as my friends can download it. With that much bandwidth to play with, I just have to do some hosting.
Even if you don't have a super-speedy ADSL line, hosting your personal websites at home can work very well, especially if they're generally low-traffic. Not only do you save a little cash on hosting fees, but you gain the flexibility to install and run whatever web serving or application software you like, rather than shopping around for providers that offer what you prefer to use.
Setting up the web server itself is only part of the solution though -- we'll look at some tricks to make it as easy as possible for users to get on to your site, and to keep your connection running smoothly with all that extra traffic.
Server software options
Apache, which runs almost 70 percent of the world's websites, would have to be the obvious choice for your home web server. It's not a terribly small application (though it's not huge either), and it can be complex to configure at times, but it's reasonably quick, quite stable, and is extremely flexible. It's also fairly easy to get started with, thanks to distribution packages that ship it pre-configured and ready to run.
On a Debian or Ubuntu system, you can install Apache 2.0 with apt:
sudo apt-get install apache2
It should start as soon as it's installed, and automatically configure itself to run on system startup. It's preconfigured to run on the standard port 80, and it serves files out of /var/www. Dozens of add-on modules, such as PHP, can be easily installed and automatically configured through apt as well.
If you're running a small system, and Apache seems like overkill, you might want to try a lightweight web server like LightTPD (www.lighttpd.net). It's small, very fast and efficient, and has a fairly impressive set of features. It doesn't support plug-in modules for extensions like PHP, but it can run scripts through more traditional methods like CGI. It also implements FastCGI, which lets you run external scripts without the overhead of launching a new interpreter for each request. The developers claim that LightTPD running PHP with FastCGI is just as fast as Apache running with its PHP module.
Once you've installed your web server, you need to make it accessible to the outside world. If you run a Linux gateway, and you've installed the web server on that, then you should be good to go as long as your firewall allows incoming access to port 80. If you have a dedicated ADSL router, you'll have to check the manual to see how to configure it to forward requests on port 80 through to your web server, though it's usually quite straightforward. You might also need to look in to any port blocking that your ISP might do. Many ISPs block a number of incoming ports, including 80, though some (including iiNet) let you disable this.
With that done, external users should be able to access your web server by typing your IP address in to their browsers.
Master of your domain
No-one likes to type in IP addresses though, so you'll really need to get yourself a domain. There's one slight snag to this though -- most home ADSL connections don't have a static IP address, so the IP address of your connection can change each time you connect. Some ISPs offer reasonably-priced static IP plans, but if yours doesn't, you can still register a domain, though you'll have to pay for DNS hosting, and you'll also need to update your IP address manually whenever it changes.
A cheaper and easier option is to use a dynamic DNS service, like the one offered at http://dyndns.org. Instead of registering your own domain, these services give you a subdomain on their already established domain. It may not be quite as nice as having your own domain name, but these services are often free, and they save a lot of hassle.
Once you've registered a subdomain on a site like dyndns.org, you can log in to your account through your browser to update your IP address. Alternatively, you can run an automated process that checks for changes to your IP address and automatically submits them for you. Some ADSL routers have this kind of functionalty built-in, with support for a number of the popular dynamic DNS providers, though on a Linux system you can download a script like ipcheck (http://ipcheck.sourceforge.net/). With some option-tweaking, you can even run ipcheck on a PC behind an ADSL router that doesn't have dynamic DNS support -- it can parse the status pages on various routers to determine your IP address.