I am looking into developing a small (read:rudimentary) web server on a linux platform and I have no idea where to start.
What I want it to be able to do is:
I am familiar with HTTP headers and am an experienced PHP and .Net web developer, but I am not sure where to start with this task.
Can you advise me with some resources to bridge the learning curve?
A web server is a piece of software that accepts HTTP requests (e.g. GET requests for HTML pages), and returns responses (e.g. HTML pages).
From top-down, you'll need to know about:
So you will have to learn about writing a basic Unix application, BSD socket programming for the TCP/IP network programming, and the HTTP protocol.
Commonly used texts include:
Unix application development:
TCP/IP (sockets) programming:
HTTP Protocol
For a SIMPLE/BASIC/ULTRA-LIGHT HTTP Server, the program flow should be something like that (in pseudo-code):
----Main thread---- Load settings while true do Wait for connection Connection received, create a new thread and transfer this connection to this thread. end ----Connection thread---- Analyze request if dynamic content do Dump the HTTP request and send it to the interpreter Wait for response from the interpreter Read response header from the interpreter Stream response else if static content do Load requested file Stream file content end (Optional) Cache the response if size < X Send the response Close the socket
So you should learn Threading, Interprocess-communication (if you want to interact with an interpreter), Socket programming and the HTTP Protocol.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With