Web Server Introduction
In web development, the server side is the software that connects multiple user applications together. You can think of the server as a hub that many clients use to talk to each other.
The server keeps the data in a persistant manner, and so it is also used to store a specific client's data (for persistancy).
For the sake of example, let's take a task management applicaiton. One option for storing the tasks data is save everything locally. This works but can be tedious for users - when a user switches computer or browser, she no longer has access to her data.
The server allows you to save the data remotely, and access it from any computer. Tasks that are stored on a server can also be shared with other users.
Another advantage is that a web server usually has more resources than a client (better connectivity, more storage space, fater CPU), so by delegating some application tasks to work on the server, out apps can actually work faster.
How Does It Work
A client talks to a server in a protocol named HTTP. When a website loads, the client requests the main page, images, stylesheets, and other resources using an HTTP GET request, and the server sends the data.
Each HTTP message contains one or more headers and sometimes the request also has data. Here's an example HTTP request:
GET / HTTP/1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11
If-Modified-Since: Sat, 08 Dec 2012 07:41:50 +0000
A web server, then, is a program that "speaks" HTTP: It can answer HTTP requests with valid HTTP responses.
If the web server is the program that speaks HTTP, a good idea is to write it in a generic way. Take the HTTP request/response part, and maybe other tasks, and create an application that does ONLY those things. This application is our web server.
For each application's specific logic, we'll build an "addon" or "plugin" that runs inside the web server, takes the data, parses it and returns the response to the wrapping web server, so it could turn it into valid HTTP response.
Writing code this way saves us the trouble of writing the same code over and over, and repeating the same mistakes.
There are several web servers that we can use to host our application. Some of them are generic, which means they can run applications in multiple programming languages. Others are bound to a specific language. On the generic front, you can find Apache and NginX. And language specific servers include JBoss and Tomcat for Java developers, Starman and Hypnotoad for perl developers, Tornado] for Python, Thin for Ruby, and many more.