Script timed out before returning headers: index.php is sometimes caused by a badly written script, or the script took to long to execute.
To solve this problem on a CPanel server you have to slightly increase the TimeOutdirective using Web Host Manager “WHM”.
To do this visit WHM > Apache Configuration > Global Configuration
Search for TimeOut and slightly increase it’s value in seconds. If the error still exist, slightly increase this value until the problem is resolved. Once fixed, try to re-look at your script.