The relationship between apache and php
Taking the Apache server and php language as an example to explain the access process of dynamic websites https ://www.cnblogs.com/sunscheung/p/4643281.html
At present, website pages are mainly divided into static pages and dynamic pages. Websites composed of purely static pages are relatively rare now. Large websites Dynamic website building technology is generally used, and some websites have static web pages and dynamic web pages coexisting.
This article takes Apache server and PHP language as examples to explain in detail the access process of dynamic websites. Let’s jump directly to the topic of this article.
Recommended: "PHP Tutorial"
(1) The client accesses the server-side html file
S1: Through this Find the DNS server address configured by the machine, and resolve the Web host domain name in the website URL to the corresponding IP address in the Linux operating system where the Web server is located (Apache is usually used in combination with the Linux operating system).
S2: Connect to the server system of the above IP address through HTTP protocol (Hypertext Transfer Protocol), and request through the default port 80 (the default port is 80, there are other ports, and you generally do not need to enter the port when entering the URL) HTML files (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, and responds to the client browser (i.e. user).
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 (because different browsers have different rules for interpreting codes) are different, so the final page effect 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, and the corresponding Web page is parsed through the DNS server The IP address of the 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 looks for and entrusts the PHP application server to process it (the server must install the PHP application server in advance). The Apache server will process the PHP file requested by the user (such as index.php) file 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 returns the html static code to the Apache server, and the Apache server will receive the The html static code is output 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 interprets the code and finally renders the web page.
(3) The client accesses the MySQL database on the server side
If the user needs to operate the data in the MySQL database, then the database management software needs to be installed on the server side MySQL server, used to store and manage website data. Since the Apache server cannot connect to 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 parsed 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 PHP files above, the PHP application server receives the delegation from the Apache server and receives the corresponding PHP files.
S4: The PHP application server opens the php file, connects to the MySQL database on this machine or other machines on the network through the database connection code in the php file, and executes standard SQL queries in the php program 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 there is a slight difference in the process.
The above is the detailed content of The relationship between apache and php. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),