CST463 · S7 CSE

How PHP is processed by a web server

Request handling, CGI vs module mode, and what happens between the browser and the interpreter.

Module 3 Back to CST463 hub

Source: php_processing.pdf — course material by Kiran V.K., published here so it is readable without a Google account.

Servers: A Comprehensive Guide

Introduction

In this guide, we'll explore how PHP processes web requests and the different modes in which PHP operates. This understanding is crucial for anyone stepping into the world of web development and server management.

1. Web Server Request Handling by PHP

The process of how a web server handles a PHP request is a foundational concept in web development. When a client requests a PHP page, the server checks for PHP scripts, processes them, and returns the generated HTML. This ensures dynamic content generation based on server- side scripting.

Figure 1: Basic Web Server Request Handling by PHP

2. Server Modes: CGI vs. Module

PHP can operate in two different server modes: CGI (Common Gateway Interface) and Module. In CGI mode, a separate process is created for each PHP script request. In Module mode, PHP is integrated into the web server itself, leading to improved performance but requiring careful security management.

Figure from the original document

Figure 2: PHP Server Modes - CGI vs. Module

3. Server vs. Command Line Mode

PHP's flexibility allows it to run in both Server and Command Line Interface (CLI) modes. Server Mode is suited for web applications, processing requests via a web server. CLI Mode, on the other hand, is used for direct script execution from the command line, commonly used for scheduled tasks and scripting.

Figure 3: Server vs. Command Line Mode

Figure from the original document
Figure from the original document

4. Server vs. CLI Mode: Sequence Diagram and Differences

Understanding the Operational Differences

PHP is a versatile scripting language that operates in two distinct modes: Server Mode and Command Line Interface (CLI) Mode. Each mode serves a different purpose and has its own operational context.

Server Mode: Web-Based Request Processing

PHP script. The script processes the request, and the server returns an HTTP response, often as an HTML page.

CLI Mode: Standalone Script Execution

Sequence Diagram Explanation

Server Mode and CLI Mode.

Figure 4: Sequence Diagram - Server vs. CLI Mode

Figure from the original document
Figure from the original document
Figure from the original document
Figure from the original document

Conclusion

This guide has explored the various aspects of PHP processing in web servers, highlighting the differences between its operating modes. Understanding these differences is vital for effective web development and server management, ensuring optimal use of PHP's capabilities.