


Detailed explanation of the relationship and functions of php and apache
The content of this article is about a detailed explanation of the relationship and role of php and apache. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
Comprehensive summary of this article The following two articles have been published:
Detailed introduction to the relationship and role of php and apache https://blog.csdn.net/hongweideng/article/details/41723465
Taking Apache server and PHP language as examples to explain the access process of dynamic websites in detail https://www.cnblogs.com/sunscheung/p/4643281.html
Currently, website pages are mainly divided into static pages and dynamic pages, websites composed of purely static pages are relatively rare now. Large websites generally use dynamic website website building technology, and some websites use static webpages and dynamic webpages. coexist.
This article takes Apache server and PHP language as examples to explain the access process of dynamic websites in detail. Let’s jump directly to the topic of this article.
# (1) The client accesses the server-side html file
S1: Through local configuration A good DNS domain name server address looks for a DNS server and resolves the Web host domain name in the website URL to the corresponding IP address in the Linux operating system (Apache is usually used in combination with the Linux operating system) where the Web server is located.
S2: Connect to the server system of the above IP address through HTTP protocol (Hypertext Transfer Protocol), through the default port 80 (the default port is 80, there are also Other ports (generally do not enter the port when entering the URL) request the html file (such as index.htm) in the corresponding directory on the Apache server.
S3: After the Apache server receives the user's access request, it finds and opens the corresponding html file (such as index.htm) in the document directory it manages. , respond to the client browser (ie the user) with the file content.
S4: After the browser receives the response from the web server, it receives and downloads the server-side html static code, and then the browser interprets the code and finally renders the web page (due to different browsers' differences in code The interpretation rules will be different, so the final page effects rendered by different browsers for the same web page will be different).
(2) The client accesses the server-side php file
S1: This step is the same as accessing the html static web page above. The IP address of the corresponding Web server is parsed through the DNS server.
S2: It is similar to accessing the html static page above, but the final request is the php file in the corresponding directory on the Apache server, such as index.php .
S3: The Apache server itself cannot process the PHP dynamic language script file, so it finds and entrusts the PHP application server to process it (the server must install the PHP application server in advance) , the Apache server hands the PHP file (such as index.php) requested by the user to the PHP application server.
S4: The PHP application server receives the php file (such as index.php), opens and interprets the php file, and finally translates it into html static code, and then html static code The code is returned to the Apache server, and the Apache server outputs the received html static code to the client browser (i.e. the user).
S5: Same as accessing the html static page above. After the browser receives the response from the web server, it receives and downloads the server-side html static code, and then the browser Solve
#Read the code and finally render the web page.
(3) The client accesses the MySQL database on the server side
If the user needs to To operate the data in the MySQL database, you need to install the database management software MySQL server on the server side to store and manage website data. Since the Apache server cannot connect and operate the MySQL server, you also need to install the PHP application server. In this way, the Apache server entrusts the PHP application server to connect and operate the database. When managing the data in the database, you generally need to use structures. Query statement, that is, SQL statement.
S1: This step is the same as accessing the php file above. The IP address of the corresponding Web server is resolved through the DNS server.
S2: Just like accessing the php file above, request access to the php file in the corresponding directory on the Apache server.
S3: Just like accessing the PHP file above, the PHP application server receives the delegation from the Apache server and receives the corresponding PHP file.
S4: The PHP application server opens the php file, connects the MySQL database on this machine or other machines on the network through the database connection code in the php file, and executes the standard in the php program SQL query statement to obtain the data in the database, and then generate html static code from the data through the PHP application server.
S5: After the browser receives the response from the web server, it receives and downloads the server-side html static code, and then the browser interprets the code and finally renders the web page. .
It should be noted that the difference between (2) and (3) in the article is that one accesses the database and the other does not access the database, so in the process There is a slight difference.
Related recommendations:
php and Apache installation and configuration examples sharing
The relationship and role of php and apache Detailed explanation
The above is the detailed content of Detailed explanation of the relationship and functions of php and apache. For more information, please follow other related articles on the PHP Chinese website!

The article discusses PHP Data Objects (PDO), an extension for database access in PHP. It highlights PDO's role in enhancing security through prepared statements and its benefits over MySQLi, including database abstraction and better error handling.

Memcache and Memcached are PHP caching systems that speed up web apps by reducing database load. A single instance can be shared among projects with careful key management.

Article discusses steps to create and manage MySQL databases using PHP, focusing on connection, creation, common errors, and security measures.

The article discusses how JavaScript and PHP interact indirectly through HTTP requests due to their different environments. It covers methods for sending data from JavaScript to PHP and highlights security considerations like data validation and prot

The article discusses executing PHP scripts from the command line, including steps, common options, troubleshooting errors, and security considerations.

PEAR is a PHP framework for reusable components, enhancing development with package management, coding standards, and community support.

PHP is a versatile scripting language used mainly for web development, creating dynamic pages, and can also be utilized for command-line scripting, desktop apps, and API development.

The article discusses PHP's evolution from "Personal Home Page Tools" in 1995 to "PHP: Hypertext Preprocessor" in 1998, reflecting its expanded use beyond personal websites.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
