Apache Web Server, how it works?

AI Thread Summary
Apache Web Server operates as a complex software system that manages HTTP requests and responses. It typically listens on port 80 for incoming connections, forking processes to handle requests based on configurations specified in conf.d files. Understanding Apache requires familiarity with HTTP/1.0 and HTTP/1.1 standards, as these protocols underpin its functionality. For those seeking to grasp its low-level workings, it is recommended to start with a foundational understanding of web protocols and to study simpler HTTP server implementations before delving into Apache's extensive codebase. Resources such as the official Apache documentation and introductory articles can provide valuable insights, while exploring minimal HTTP server examples in various programming languages can serve as a practical starting point for learning.
mishima
Messages
576
Reaction score
43
Hi, I have recently been using Apache for a web server. I would like to know more about how it works on a low level, what exactly it does. Perhaps a pseudocode, or minimal code version exists somewhere?
 
  • Like
Likes harborsparrow
Computer science news on Phys.org
mishima said:
Hi, I have recently been using Apache for a web server. I would like to know more about how it works on a low level, what exactly it does. Perhaps a pseudocode, or minimal code version exists somewhere?

I didn't think that you can found such a thing anywhere, to be honest.
Apache is a large software complex and its functions just can't be described shortly with some pseudocode.

You can take a look at the apache docs where minimal apache internal structure is described.
Take a look here about some info about apache config and overall configuration too, may be it will help.
 
  • Like
Likes harborsparrow
Basically it opens up port 80 (usually) and listens for connections. When it receives a connection, it forks the port and keeps the connection while it calls whatever program it's supposed to use to handle the request. It uses the conf.d files to determine what to do with what request.
 
  • Like
Likes harborsparrow
Apache implments the HTTP/1.0 and HTTP/1.1 standards, so in order to understand what it's doing, you first need to understand those standards. Google them. They aren't easy to read at first, but if you continue plugging through them, you'll understand what web servers and web browsers are really doing. Very worthwhile and illuminating. I wouldn't recommend looking at Apache code unless you first understand the standards which it is implementing.
 
mishima said:
I would like to know more about how it works on a low level, what exactly it does

In order to get down there, begin at a high level meaning protocols, ports, requests, responses and the like, as has already being mentioned. If you like web development then you are on the right track. In order to get at its inner workings, you must first be an advanced programmer. And then, you'll focus on certain parts of code or modules, because the whole project is more than huge. It is very fascinating to get involved in this project some day and the same goes for the other Apache projects besides Apache Web Server, too.
 
  • Like
Likes harborsparrow
Note the OP was way back last October. :oldwink:

Nevertheless... if your goal is more in the direction of learning about HTTP servers in general (Apache being merely the 600-pound gorilla in that field), it might be useful to start by studying a very stripped-down HTTP server instead of Apache with all its bells and whistles. Typing "tiny http server" into Google leads G's autocomplete function to suggest "tiny http server c", "tiny http server java", "tiny http server python", etc. Substitute whatever language you're familiar with and you might get something useful as a starting point.

I thought of trying this search because I remembered seeing in a Perl book years ago when I was learning Perl, a code example that was a "tiny HTTP server".
 
  • Like
Likes harborsparrow and QuantumQuest
Apache is a jungle. You will need a few months to understand it. Good luck
 
  • Like
Likes harborsparrow
Back
Top