504嵌套include()的服务器错误

I have a PHP application that has multiple "nested" include() functions. For some reason the applications stops after 60 seconds. I'm using set_time_limit(0), also I have tested this without the include function in the file and it runs forever. I'm not sure what the issue is.

Working:

set_time_limit(0);

while(1 < 2){
    echo 'hello';
}

Not Working:

//MASTER FILE
set_time_limit(0);

while(1 < 2){
    include('file.php');
}

//INCLUDED FILE 'file.php'
echo 'hello';

First, it's bad practice to write infinite loops, especially in response to a web request. In general you also want your web requests to respond as quickly as possible and have long-running processes run separately.

That said, assuming you're running PHP behind Apache, you'll want to adjust your Apache TimeOut config. It defaults to 60 seconds.