简体   繁体   English

调用位于同一Apache服务器上的URL时,PHP会做什么?

[英]What does PHP do when calling a URL located on the same Apache server?

I have two PHP applications on the same Apache server. 我在同一个Apache服务器上有两个PHP应用程序。 At some point, application A needs to call a URL on application B. 在某些时候,应用程序A需要在应用程序B上调用URL。

So let's say a script located at http://somedomain.com/app1/action need to download http://somedomain.com/app2/action using file_get_contents() (the domain is the same for both applications) 因此,假设位于http://somedomain.com/app1/action的脚本需要使用file_get_contents()下载http://somedomain.com/app2/action file_get_contents()两个应用程序的域都相同)

I was wondering how does PHP handle this? 我想知道PHP如何处理这个? Is the request going through the whole internet, as if it was a call to an external URL? 该请求是否遍历整个Internet,就像是对外部URL的调用一样? Or is it somehow optimizing it and accessing the application on the server directly? 或者是以某种方式优化它并直接访问服务器上的应用程序?

I think it depends from your DNS resolution and is not related to PHP. 我认为这取决于您的DNS解析并且与PHP无关。

If your network is properly configured, you should be able to access the site on your local network even by calling the public url. 如果您的网络配置正确,即使通过调用公共网址,您也应该可以访问本地网络上的网站。

To be sure about your request not leaving the server, you could use the localhost ( or 127.0.0.1 ) address. 为了确保您的请求不离开服务器,您可以使用localhost (或127.0.0.1 )地址。 You can also use the local ip address to access it over the local network. 您还可以使用本地IP地址通过本地网络访问它。

The whole internet is big. 整个互联网很大。 But it would unlikely leave the server, depending on the network layout. 但是,根据网络布局,它不太可能离开服务器。

It uses the whole TCP/IP stack of the operating system, if that's what you want to know. 它使用操作系统的整个TCP / IP堆栈,如果这是你想知道的。

If it's in the same server, it wouldn't have to resolve the DNS name if you use 127.0.0.1 instead of somedomainname.com. 如果在同一服务器上,则如果您使用127.0.0.1而不是somedomainname.com,则不必解析DNS名称。

Usually request do not "go out" of your server, so application B is accessed quicly by application A. 通常请求不要“离开”您的服务器,因此应用程序B可以快速访问应用程序A.

Requests can "go out" in the wild and then being routed back to your server (and that's not so good for performance) if your server DNS are not configured well (pratically, your server can't recognize itself as somedomain.com ). 如果您的服务器DNS配置不正确(通常,您的服务器无法将自身识别为somedomain.com ),则请求可能会“狂奔”出去,然后被路由回您的服务器(这对性能不是很好)。

The request goes through every server between the source and the destination. 请求通过源和目标之间的每个服务器。 Since they are the same, that is no servers. 因为它们是相同的,所以没有服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 同时调用2个或更多php文件时,Apache(php)崩溃 - Apache (php) crashes when calling 2 or more php files at the same time Apache PHP检查文件是否存在-is_file在服务器上实际做什么 - Apache PHP check if file exsists - what does is_file really do on the server 使用 AJAX 连接到服务器端 PHP 时,我对 URL 使用什么 - What do I use for URL when using AJAX to connect to server side PHP 输出与服务器提供的URL相同的URL的程序(PHP,JSON) - Program that outputs URL same with what is provided by the server(PHP,JSON) @url做什么? - what does @url do? 当我输入没有DNS解析的有效URL时,PHP curl和file_get_contents返回位于服务器上的主网站 - PHP curl and file_get_contents returns the main website located on the server when I enter a valid URL without DNS resolution 在同一Apache服务器上并行运行PHP 4和PHP 5的最佳方法是什么? - What is the best way to run PHP 4 and PHP 5 side-by-side on the same Apache server? PHP:CURLOPT_URL 到底有什么作用? - PHP: What does CURLOPT_URL really do? 什么事 在php中读取和解释URL时的意思 - What does ? mean in php when reading and interpreting a URL 无法在 apache2 httpd 服务器上配置 php。 找不到 php 模块 where.so 文件所在的位置 - Unable to configure php on apache2 httpd server. Unable to find php modules where .so file is located
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM