Home>Article>Backend Development> Detailed introduction to the relationship between php and apache
#php is currently the most popular programming language, driving more than 200 million websites around the world. At the same time, it is free, open source, and easy to use. It has become an indispensable tool for programming beginners. Second choice, if you want to learn PHP, you must learn Apache. However, for beginners, how to figure out the relationship between the two has become a threshold. So next, I will explain the relationship between the two for everyone's convenience. In future studies, we will better understand how the two work.
First of all,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 convert the domain name according to the domain name. It is resolved to the corresponding IP address, such as IP address192.168.1.100
. Because the default port of the domain name address is port 80, 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 port number is used 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.
Next, if I enter the address in the client browser, he will find the server192.168.1.100
, and then based on the port Find the apache server. 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?
Finally, if you enter the address in the client browser, it will send the address to the apache in192.168.1.100
, apache will take a look at you What is passed is a Php file. If the server does not have PHP installed, it will open the file and return all the code inside to the client, but the client browser cannot parse the PHP file.
So 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.
Recommended video tutorial:PHP video tutorial
The above is the detailed content of Detailed introduction to the relationship between php and apache. For more information, please follow other related articles on the PHP Chinese website!