The relationship and role of php and apache is a matter of great concern to many friends who learn php. This article mainly shares the relationship and role of php and apache with you, hoping to help everyone.
First, enter the URL in the browser on a client computer. For example, if our computer is online, there will be a DNS server. Its function is to resolve the domain name into the corresponding IP address, such as the IP address 192.168.1.100. , because the default port of the domain name address is port 80, so the final resolved address is: http://192.168.1.100:80. Then the network will find its corresponding server based on this IP address. This server is the base of the website. Website programs and the like are all placed on this server. There will be a lot of software installed on this server. For example, MYSQL, WEB server (apache server), qq, etc. There is also a port number 80 in the address transmitted from the Internet. The IP part of this address is used to find this server, and the function of this port number is to find the specific application on this server. Because the default port of the WEB server is 80, this address is looking for the web server in this service area. Because we mainly talk about PHP here, we choose the Apache server.
The following is an example. If I enter the address into the client browser, it will find the server 192.168.1.100, and then find the apache server based on the port. Apache will return the code in index.html in a certain directory to the client's browser through the URL address, and then the browser will parse it into the web page content we see based on the returned code. This is what happens when we access the code of a web page. What if we are accessing a PHP file? When the server does not have PHP installed, it will also open the file and return all the code inside to the client, but the client browser cannot parse the PHP file. Therefore, the front desk will display all the code of this file, or there will be a situation of downloading this file. This is not what we want to see. So we need to install a php service on the server side, so that when apache sees that the file you sent is a php file, it will first pass the file to the php program, and the php program will first interpret the file. Then he returns it to apache, and apache returns it to the client. In this way, the client can see the page effect after parsing the php file.
The above is the role and process played by the apache server and php in the client browsing a php page.
The relationship and functions of php and apache have been introduced to you. I hope my friends will gain something after reading this article.
Related recommendations:
Some common codes for php and apache pseudo-static PHP and APACHE configuration error Notes on setting up PHP and Apache environment_PHP tutorialThe 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!