> For the complete documentation index, see [llms.txt](https://courses.learnwithprayag.com/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://courses.learnwithprayag.com/linux/web-server.md).

# Web Server

## **Introduction to Web Servers**

### **What is a Web Server?**

A **web server** is software that handles **HTTP requests** from browsers and returns **HTTP responses** containing web content. It allows users to access websites over the internet or intranet.

#### **Types of Content Served:**

* **Static Content:** Pre-written files such as HTML, CSS, JavaScript, and images.
* **Dynamic Content:** Generated at runtime based on user input, sessions, or data queries.
* **Multimedia Files:** Videos, audio, and images.

***

### **Functions of a Web Server**

Web servers can:

* Receive and process **HTTP requests**
* Serve **static pages**, **dynamic pages**, and **multimedia**
* Handle **multiple concurrent connections**
* Ensure **security and access control**
* Be **scalable** and **customizable**
* Work with **multiple programming languages**
* Offer **high reliability** and **cost-effectiveness**

***

### **Static vs. Dynamic Content**

| **Content Type** | **Description**                                      |
| ---------------- | ---------------------------------------------------- |
| **Static**       | Pre-rendered and stored files, served without change |
| **Dynamic**      | Created in real-time based on logic, code, or input  |

***

### **Web Servers for Popular Languages and Frameworks**

| **Language / Framework**   | **Static Server**   | **Static Content**              | **Dynamic Server**    | **Dynamic Content Description**                      |
| -------------------------- | ------------------- | ------------------------------- | --------------------- | ---------------------------------------------------- |
| PHP (Laravel, CodeIgniter) | Apache / Nginx      | HTML, CSS, JavaScript           | PHP-FPM               | Executes PHP scripts for dynamic content             |
| Ruby (Rails)               | Apache / Nginx      | Static files like CSS, images   | Puma, Unicorn, Thin   | Handles HTTP requests and runs Ruby code             |
| JavaScript (Express.js)    | Apache / Nginx      | HTML, CSS, JS                   | Node.js               | Node environment runs JavaScript for dynamic content |
| Python (Django / Flask)    | Apache / Nginx      | Static assets                   | Gunicorn              | Interfaces with web server for Python apps           |
| Java (Spring Framework)    | Apache Tomcat/Jetty | Serves static files efficiently | Apache Tomcat / Jetty | Java servlet container for web apps                  |
| ASP.net Core               | Apache / Nginx      | CSS, JavaScript, images         | Kestrel               | Optimized web server for .NET Core                   |

* Web servers are critical for delivering content over the internet.
* They serve both static and dynamic data based on application needs.
* The choice of web server depends on the development stack and performance requirements.
* Understanding static vs. dynamic handling helps with scalable web architecture.
