title: How to debug a PHP script that never finishes loading?
body: <p>I have been tasked with setting up a website on various environments for different stages of evaluation (dev/test/staging/etc).</p>
  
  <p>On our staging environment however, it seems there is some difference preventing the PHP script from finishing, so the page is never delivered to the browser.</p>
  
  <p>I'm wondering if there is a way I can output to log some sort of stack trace or backtrace upon cutting the connection, or is there some other method to find out what exactly PHP is doing at any given point in the script's life cycle?</p>
  
  <p>It's a Drupal site, so it involves a lot of code I'm not familiar with, and could take hours to sprinkle <code>die;</code> commands throughout to see where the script is loading to.</p>
  
  <p>I understand I should probably be looking at the differences in environments, however all should have very similar configuration (Ubuntu 11.04) and the staging environment seems entirely happy to serve other PHP sites whilst this particular site is refusing to finish. If anything this staging site has more resources available that other environments which are not having problems.</p>
  
  <p><strong>UPDATE</strong>: Sorry all, found the problem in the end. The staging environment was on a VLAN that was not permitted to access itself via public IP, and for whatever reason (still confused about this) it was trying to access itself as part of the page load and never completing the request. Setting a hosts file entry for 127.0.0.1 fixed the issue.</p>