Building a perfect web-server |Part 1

Planning your web server

The first thing we have to do when you are about to build the perfect Linux server is to ask yourself
what it is you want your web-server to do.

That may sound like a dumb question, but answering it will save you hours and hours of work and allow you to concentrate on the things that matter rather than getting bogged down in pointless detail.

There are many, many Linux distributions on the Internet and you may find that someone has already built it for you.  It is better to build on the shoulders of giants.

What is it you want your web server to do?

If all you want the server to do is serve up a few static web pages then I would suggest that you don’t build a server at all.  Just spend $5 a month on hosting and get on with producing the content.

But let’s assume we are building a server…

A general purpose web server that can serve up PHP and connect to it’s own Mysql database

Now it is an application server, not just a web server. That is fine. We defined it early on and spent no money or build time on it yet

Because there are hundreds of PHP web applications that run out of the box on Mysql and Apache
I am going to stick with explaining how to do it on  Linux, Apache, Mysql and PHP (or LAMP).

So now we know what we are building an Application Server.  But we also want it to be secure, reliable and easy to maintain. It must also be easy to replicate to a new machine, automatically.

I have seen and built enough Linux servers in the last 16 years to know that reliability and robustness is a double edged sword. By the time the thing actually breaks there is nobody left who remembers what is on it. Therefore, it is important that it can be replicate without specific prior knowledge. If you don’t have an automated build system then you will need to reverse engineer it. I’ll cover this in another article but we will just do it properly to start with.

Right! lets get cracking. Who is the Application Server for?

If it is just you and a few friends by all means run it on the second hand machine with 1 GB of RAM and a power supply that hums unless you kick it.

If you want a real Linux server that is going to service a business then it is a different story.

Just because Linux can run on the old hardware does not mean it should. I really wish people would give the same amount of budget to the web server that makes them money as they do to the laptop that they use for Facebook!

What specifications do you need?

To save you hours and hours of trawling through 100’s of websites here are the specifications you’re going to need to service a business running a couple of Mysql apps and a database driven web site.

You can make it more complex but you don’t need to. If you need more power just add more of the same servers and a load balancer and perhaps a dedicated database server. It is way more robust.

  • 1 x SSD good quality enterprise Solid State drive.
  • 1 x 1TB mechanical drive
  • A Motherboard to support at least 16GB of RAM
  • 16GB of RAM.
  • A CPU. An i5 or, if you can stretch to it, a Mid level Xeon
  • A rack/tower case with a good power supply
  • Compatible network card
SSD drive for web server

These are amazing for systems that are serving small amounts of data to users, If they have to write to the disk it is incredibly fast and will feel, and be, snappy. This is a web server and now a database server. It will handle a lot of small disk writes and a lot of reads. I like the Intel SSD drives because they pretty much do what they say on the box.

Mechanical Drive

We are going to use this for “on system” backup of the system. Just put a reasonable one in.

RAM

Put in as much as you can afford, it will speed up your server because Apache is a little memory hungry. Nginx is better at managing memory but we can look at that later.

CPU

There was a time when this was everything but over the last few years I have rarely seen a system run out of CPU before RAM and Disk speed. Of course as soon as the RAM starts swapping to disk the CPU load goes through the roof, but we have avoided that by specifying fast disks and lots of RAM.

Network card

This is one place that if the budget allows I would splurge. Get two! Make sure they are recognised by the kernel and are of course Gigabit speed. For historical reasons I avoid Realtec. You should be able to get all that in a rack mount case for around $1500.

Slap down the credit card and we can finally start looking at software while we wait for the hardware to arrive.

Building a perfect web server | Part 2