0

I experience problem with PHP request on self. In example I will use file_get_contents() but same happen for exec('wkhtmltopdf [*SELF*]') or curl()

  • lets name my server example.com
  • apache2 installed
  • FastCGI (multiple PHP versions 5.3, 5.4, 5.5, 5.6, 7.0)
  • now I have 2 dummy scripts


1st script

//get-html.php  
file_get_contents('http://example.org/index.html')

2nd script

//get-php.php
file_get_contents('http://example.org/index.php')


Testing
1) command-line: php get-html.php // Success
2) browser: example.org/get-html.php // Success

1) command-line: php get-php.php // Success
2) browser: example.org/get-php.php // Timeout


What I tried next

  • create subdomain like subdomain.example.org/index.php to have differet PHP version for get-php.php and for index.php
  • amend /etc/hosts
  • request on other sites (like google.com) // Success
  • session_write_close() before file_get_contents() and session_start() right after does not work also

So my suspect is mod_fastcgi. It seems like the apache is not able to run 2 instances of this to handle PHP requests which comes from itself. As running script from command line works as expected.

Does anybody have any advice?

Nedvajz
  • 891
  • 8
  • 13
  • Are the dummy scripts complete? You don't use sessions (they might block as well) – Mark Aug 30 '17 at 06:00
  • Good point Mark. Forgot to mention. I have also tried session_write_close(); file_get_contents('http://example.org/index.php'); session_start(); But that was not successful as well. Updating 'What I tried next' section now. – Nedvajz Aug 30 '17 at 06:07
  • Please don't start session (or use it at all) for now and try again, that would answer our question if the problem is caused by blocking session or something else. – Mark Aug 30 '17 at 06:09
  • `session_write_close(); file_get_contents('example.org/index.php');` same result though :-( thanks for ideas – Nedvajz Aug 30 '17 at 06:19

1 Answers1

1

I did not set PHP_FCGI_CHILDREN what is in default 1.
When I called in PHP script another PHP script from my server over apache it failed as it was not able to create another PHP FCGI instance.

Proper settings of PHP_FCGI_CHILDREN

Nedvajz
  • 891
  • 8
  • 13