How To Run Your Own Webserver
For some time, I’ve run my own web server from the comfort of my own home. I made this decision due to the fact that I wanted more control over my server, and I wanted to run as many web development languages side by side as I could, and mainly because I wanted to run SVN. Before I started hosting my own websites, I had a sketchy knowledge of how the DNS works, and how to go about hosting your own websites on a Linux operating system. I also had minimal Linux administration skills.
There are a few good reasons for hosting your own website:
- No artificial caps on bandwidth and hard disk usage. You pay for what you use, and if you need more, you buy more.
- Total control over your hosting environment. If you want a language installed, install it. If you want to run a certain version of Rails, run it. It’s your server.
- Experience. Hosting your own websites on your own server can give you a lot of experience with systems administration on a server operating system.
- Cost. You have complete control over how much everything costs, and you know exactly where your money is going. You can spend as much or as little as you wanted.
How Do You Do It?
First, it helps to get an idea of what you really want. Do you want to run a huge corporate intranet with load balancing and proxy servers, or do you just want a small server to host personal sites and tinker? Is your budget limitless, or are you already living on ramen for dinner 5 nights a week? Do you want to host proprietary languages like Cold Fusion or ASP.NET, or will a Linux/Apache install satisfy you?
Personally, I was only interested in hosting personal sites, and doing it cheaply was my utmost concern. This is what I will focus on, as this is what I have experience in. So, what I was looking for was a relatively easy solution that was above all cheap.
1. Get Your Hardware
Before you can start, you need to have hardware to put your server on, and if you already don’t have it, appropriate networking gear to support multiple computers accessing the same internet connection (if you want to use a personal computer as well).
As your end goal is a web server, this server preferably needs to be up 24/7, which means whatever hardware you choose to run it on will essentially cease to exist with regards to usage. Most of the time, hopefully, you’ll never need to do much work on the server itself, only transferring data to and from it.
I already had my networking gear, and I commandeered an old desktop computer for my server. It was a Pentium IV 3.0GHz with 2GB of RAM. I found in the year or so I ran the server that my memory usage didn’t ever go above ~400mb. I also had a 120GB hard disk in there. This computer used to serve as my old gaming workstation, however I don’t play games much these days, and I bought a laptop that was more powerful.
2. Get Your Software
I chose to run CentOS 5 as my Linux distribution. My choice was admittedly relatively arbitrary, however I was relatively happy with the choice. I installed the OS and included only the packages that I knew I needed – that meant no xserver, and no GUI. I was going to administrate this server via ssh on my laptop. I then updated the OS and installed all the required software.
I immediately recognised that it would be hard to individually install and hook up everything that I wanted to run, and decided to run a web-server software package to help. I eventually settled on Webmin after a few false starts, and Webmin proved to be very user friendly and relatively powerful. If I was doing the same thing again, I would be relatively comfortable doing it all individually without Webmin, but it was Webmin that provided me with a safety net while learning.
3. Get Connected
I was already running the biggest Internet providing plan that my ISP offered. As I live in Australia, we have to live with usage caps on our Internet plans. Mine was 20GB download during peak traffic, 40GB download during off-peak, and unmetered upload. This was perfect for hosting a server, as most of my traffic was upload, once I got everything installed.
However, you do need more than just an Internet connection to get a server online, you also need a static IP address. Technically you can do it with a dynamic IP and a dynamic DNS service, however that was a level of complexity I didn’t have the patience to deal with. So I put a static IP on my account as well.
Cost: $10/month for the static IP, Internet was free because I was using the connection anyway
4. Get Hosted
This is the final step to getting your server ready to host websites. So far, you have a server with the software installed, and you have an Internet connection and a static IP. You can type your static IP in a browser and get your Webmin’s default landing page (if your router supports NAT loopback, which mine didn’t). To get your web server attached to a domain name, you first must register the domain name, then point it to nameservers that run a DNS server.
You could run the DNS server on the same machine, or a different machine, but that was all too complicated for me. I instead chose to get a hosted DNS solution with Nettica, and have Nettica manage my name servers. Then it was simply a matter of pointing my domains to the Nettica nameservers, pointing my Nettica entries to my server IP, and add the virtual servers with Webmin, letting it take care of configuring Apache for named virtual hosting.
So that’s it. For about $170/year, I could host my own server and serve as many websites as I had room for on the Internet. I had complete control over the server, and I could install what I wanted, when I wanted.
I don’t run the server now, as I have recently moved to a location where I cannot justify it, but overall I found the experience very rewarding. Sure, you can get cheaper shared hosting, but there’s nothing like deciding you want to install, say, SVN and just installing it, and having it up and ready in 10 minutes for no charge.