I like my tech, and I’m basically a skinflint, so rather than pay for web hosting, I decided to do it all myself, I know about this kind of stuff so it can’t be that hard right? Well if you’re like me and you host your websites at home, you’ll be aware, that it’s a great idea, you’ll also be thinking, what the hell am I doing this for? Let me explain a little.
I used to work for a UK web hoster, while I was with them I used to get free webhosting, which was perfect for all my sites. I didn’t have to worry too much about uptime etc as it was done by the companies tech team. Then came my time to leave the company, I moved onto something far better, this meant that I’d have to start paying for my hosting and at about £30 quid ish a month minimum, wasn’t something i was prepared to pay out for. So what would I need to have/do to get my sites moved and up and working.
I knew I needed a web server, I knew I needed Linux, so lets get cracking. Server purchased check, [plug for http://www.bargainhardware.co.uk/%5D, os downloaded on a cd, in my case I’ve chosen the Ubuntu OS, I’m not going into a debate about why ubuntu is better/worse than the next distro, it’s just something I picked. I then had to sit down and think, did I want just a webserver, or would there be other things I’d need to use the server for? In my case yes, I needed a web server, my kids wanted a minecraft server, I wanted to play about with IRC so I needed a shell server and a few others. KVM was the way to go for me. Ubuntu installed, picked the options at the beginning to have a SSH server and Virtual Host and boom, all setup, well kinda.
The servers I have, have two nics, as I’m no longer with the professional web hosting company, I knew I’ve have to think about redundancy, even if it was very basic, so I bonded the network cards, which basically means if one of them failed, the other would take over. Well that’s all well and good, I hear you cry, but what happens if the switch fails? Well that’s an easy one, I’ve got two switches, one nic attached to one, and the other nic in the other, one switch fails, the other takes over.
Ok but what about hard drive failure/or complete system failure? Well that’s easyish too, I have two hard drives mirrored in the server, one fails the other takes over. BUT YOU CAN’T MIRROR MEMORY OR CPU MELLORS.
Ok you got me there, I’m pretty must limited by the hardware, if some major part fails I’m screwed…but am I? In my setup, I decided that I’m going to mirror hardware as well, so I purchased another server with the same spec as the first, that was the easy part, same OS install, same kvm install, same setup for bonding. I then decided that I needed a way to sync data, as the virtual machines are only a couple of files, I wanted to make sure they sync, so that if one physical server fails, I can use the other. I was going to rsync the data over, but this would mean I have to setup cron to run a scheduled task, and the data could be out of sync between the two machines, depending on how often I setup the rsync to run. I could have a third server that just acts as a data store and use both servers to access that, but then if that fails, I’ve lost access to data, so that was a no go, hmmmmm
After a bit of research I came accross a software system called glusterfs [http://www.gluster.org/], I’m not going to explain the tech details here, but basically it allows me to setup my systems, so that if data is written to one server, it’s immediately written to the other which keeps both servers constantly in sync, RESULT.
So there we have it, my webhosting setup in a nutshell, which works quite well for me, it’s not perfect i tell you, I mean I don’t have redundant internet access, as it’s Virgin Media [yes i’m allowed to run a server on the connection], it’s not a static IP address, but for me it works well, and all it costs is a bit of time and knowledge + the electricity at home 🙂
Any questions about this, give us a shout, I can’t promise I’ll be able to answer them, but I’ll give it a shot or point you in the right direction.
PS, If you need a professionally hosted website, then self at home hosting isn’t the way to go, uptime can be terrible and the outages can be any time, if you need this, then you will need to pay for hosting. I’m just using this as it works for me 😀