Primer: Web Servers, Web Apps, Databases and Hosting

[This post is a transplant from another blog that I have since shut down. I occasionally need to point people to a primer like this one, so I'm reposting it here.]

Even as a technical person who has spent most of their career programming or managing programmers, I was pretty confused when I first dipped my toes into web development. I really wished I had a simple primer that put things like the web server, web applications, the role of the database and hosting into perspective. Now that I have a better understanding of it all, I thought I’d try to write the simple primer that I was missing. Here’s a stab…

What is the web server?

This is the PC that you connect to the Internet to “serve” web pages. Other PCs on the Internet then send it requests for a page (the home page, for example) and the web server sends that page back to them. People use a web browser to send the request, and then the browser also interprets your web server’s response and displays it nicely on their screen.

So the “web server” is this server PC, but when people say “web server” they also mean the software running on this PC that interprets incoming requests and sends back the response. In our case, we are using the “Apache” web server, but there are also other options, like Microsoft’s Web Server offering.

What gets served?

Obviously the web server is not all you need. You also need some content for it to serve. This is as simple as adding the content to a folder on the server PC that the web server software knows about. Normally the content takes the form of files in the HTML format and the associated images that they use. In the early days of the web, it was *only* HTML text files and images that web servers “served”, but these days the web servers are way more sophisticated and can serve much more interesting content (videos, applications, etc.).

What is a web application?

There was a time when web servers only served up static content. You put a bunch of text files, images and videos into that special folder that the server knows about, and then people could view that content with their web browsers. At some point someone added some functionality to the web server that allowed it to dynamically serve up different content under different conditions. So the web pages now included logic, not only content. They became “applications”, as opposed to mere “pages”.

Why the database?

This is easiest to explain with an example. Take a blog. You could make your blog by manually creating a page for the front page, and then pages for each individual page. Each time you added a blog entry you would manually add it to the front page, move the last blog entry off the front page, and manually create the separate entry in a separate page. Clearly this is a crazy amount of work for each entry.

With a database, you can store the entry text as a record in the database. Then you have a blog “application” running on your server PC, working together with your server software. It takes entries from the database and formats them nicely for visitors to your blog. This application can format the blog entries in an infinite number of ways, with no change to the entries themselves! So if you wanted your blog entries to appear in a grid instead of the normal chronological order, you would only need to change the logic in the application.

What is WordPress?

WordPress is a blogging application that runs on a web server. It has a back-end part that makes it easy for you to add entries to your database, and it has a front-end part that displays these entries to your visitors. It is a big pile of HTML, CSS, javascript and images, but you install it the same way you would install the simplest of HTML web pages – you put it in that special folder that your web server knows about. There is some additional configuration, most importantly setting up the database that it will use to store your blog entries, comments, etc., but it is essentially just a web application that runs on top of your web server.

What is hosting?

You could run your own web server at home. You would buy a PC, install Apache or Microsoft Server, and install WordPress. This would probably be unreliable though. You probably don’t have a proper cooled environment, with backup servers and a high bandwidth connection to your home. So people normally let a company that specializes in managing web servers do it on their behalf. This company “hosts” your web server. Logically, it is as if they put your server PC in their datacenter and managed it for you. You can log in remotely and add content to your web server, but they look after it and keep it running.

In my case Media Temple is hosting the web server. I installed WordPress on the server, but they are hosting the server itself. You can take this hosting concept even further. Sites like Blogger.com also do hosting, but they host the web server AND the blogging application. There is a big difference, because in this situation you have way less control over your blog, and you don’t have the option of installing applications other than the blog (a forum, for example).