On my development PC running Windows 7 I’m trying to simulate a simple server-to-server arrangement like this;
Script /test/index.php
<?php
echo "<div>hello</div>";
echo file_get_contents("http://localhost/test/server.php");
?>
Script /test/server.php
<?php
echo "<div>world</div>";
?>
But when I point a browser to http://localhost/test/ I get no response. The browser just hangs. However if I replace server.php with a file called server.html containing only this;
<div>world</div>
then I get the wanted response of;
hello
world
Why does the first method not work? Should it work?
Info
I’m running PHP by doing this command on the command line;
php-cgi -b 127.0.0.1:9000
I’m using nginx as my web server. In my nginx.conf file there’s a line;
worker_processes 1;
Somewhere in the nginx documentation it said that you should always set the above to a value of 1 on Windows machines but I don’t know what effect that setting has or if it has anything to do with my problem.
PHP requires a process per PHP page being server. In your scenario, you are only allowing one request to be processed at a time. When you first request causes a second PHP request to be served, the system effectively deadlocks while the first script waits for the second script to run, which it never will as only one script can run at a time.
Increasing the worker processes will allow multiple concurrent scripts to run.