PHP request on self

879 views Asked by At

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?

1

There are 1 answers

0
Nedvajz On BEST ANSWER

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