search
HomeBackend DevelopmentPHP ProblemThe relationship between apache and php

The relationship between apache and php

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

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

PHP Secure File Uploads: Preventing file-related vulnerabilities.PHP Secure File Uploads: Preventing file-related vulnerabilities.Mar 26, 2025 pm 04:18 PM

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.

PHP Input Validation: Best practices.PHP Input Validation: Best practices.Mar 26, 2025 pm 04:17 PM

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.

PHP API Rate Limiting: Implementation strategies.PHP API Rate Limiting: Implementation strategies.Mar 26, 2025 pm 04:16 PM

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

PHP Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

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

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.Mar 26, 2025 pm 04:13 PM

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.

PHP XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

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

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

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),