Currently, website pages are mainly divided into static pages and dynamic pages. Websites composed of pure static pages are relatively rare. Large websites generally use dynamic website construction technology, another part of the website is the coexistence of static and dynamic web pages. This article takes the Apache server and php language as an example to explain the dynamic website access process. The following describes the topic of this article.
(1) access html files on the server from the user end
S1: Find the DNS server through the DNS server address configured on the local machine, resolve the Web host domain name in the website URL to the Linux operating system where the Web server is located (Apache is usually used in combination with the Linux operating system).
S2: bytes ).
S3: After receiving the user's request, the apacheserver finds and opens the corresponding HTML file (such as index.htm) in the corresponding management file, and returns the file content to the client browser (that is, the user ).
S4: After the browser receives a response from the Web server, it receives and downloads the html static code from the server, and then the browser interprets the code, the web page is finally displayed (because different browsers have different interpretation rules for the code, different browsers may have different final page effects for the same web page ).
(2) access the PHP file on the server
S1: This step is the same as accessing the html static webpage. the IP address of the corresponding Web server is resolved through the DNS server.
S2: similar to accessing the html static page above, but the final request is the php file under the corresponding directory on the Apache server, such as index. php.
S3: the Apache server itself cannot process php dynamic language script files, so it looks for and entrusts the PHP application server for processing (the server must install the PHP application server in advance ), the Apache server returns the PHP file (such as index. php) file to the PHP application server.
S4: PHP application server receives PHP files (such as index. php), open and explain the php file, and finally translate it into html static code, and then return the html static code to the Apache server, the Apache server outputs the received html static code to the client browser (that is, the user ).
S5: similar to accessing the html static page above, the browser receives and downloads the html static code from the Web server after receiving the response from the Web server. Then, the browser interprets the code and displays the webpage.
(3) Access the MySQL database on the server end from the user end
If you need to operate data in the MySQL database, you need to install the database management software MySQL server on the server to store and manage website data. Because 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 to and operate the database, when managing data in a database, Structured Query statements (SQL statements) are generally used.
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: like accessing the PHP File above, requests to access the PHP file under the corresponding directory on the Apache server.
S3: like accessing the PHP File above, the PHP application server receives the Apache server's delegate and receives the corresponding PHP file.
S4: Open the PHP file on the PHP application server. Use the database connection code in the PHP file to connect to the MySQL database on the local machine or other machines on the network, in the php program, you can execute standard SQL query statements to obtain data in the database, and then use the PHP application server to generate html static code.
S5: After receiving the response from the Web server, the browser receives and downloads the static html code from the server. Then, the browser interprets the code and displays the webpage.
Note that the difference between (2) and (3) Is that one accesses the database and the other does not, so there is a difference in the process.