The relationship and role of php and apache is a matter of great concern to many friends who learn php.
So why does the server need to install the php environment?
First enter the URL in the browser on a client computer. For example, if our computer surfs the Internet, 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 placed on this server, and a lot of software will be 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.
For example, if I enter the address in the client browser, he 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?
For example, if you enter it in the client browser, it will also send this address to apache in 192.168.1.100. When apache sees that the file you passed is a Php file, if PHP is not installed on the server Next, he will 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 pass the file to the php program first, 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 content is for reference only!
For more related content, please visit the PHP Chinese website: PHP Video Tutorial
The above is the detailed content of What is the role of installing the php environment on the server?. For more information, please follow other related articles on the PHP Chinese website!