The following script:
<?php
$dnsrecs = dns_get_record('google.com'); foreach($dnsrecs as $dnsrec){ foreach($dnsrec as $label=>$val){ echo $label.':'. $val . '<br>'; } }
echo file_get_contents('https://google.com');
?>
Gives back a list of DNS records, but ends up failing on the file_get_contents, although phpinfo() says:
allow_url_fopen On On
allow_url_include Off
With the following error:
PHP message: PHP Warning: file_get_contents(https://google.com): failed to open stream: php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /var/www/a.php on line 5" while reading response header from upstream, client: 152.66.34.10, server: xxx, request: "GET /a.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm-www.sock:", host: "xxx"
DNS resolution on the server works, with the same user as nginx is running:
# sudo -u www-data host google.com
google.com has address 216.58.212.142
google.com has IPv6 address 2a00:1450:400e:800::200e
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.
My PHP version is recent:
# php --version
PHP 5.5.9-1ubuntu4.21 (cli) (built: Feb 9 2017 20:54:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
I am running it via php5-fpm, and it seems to be related to that, because sudo -u www-data php a.php works correctly.
My php.ini file is here: http://pastebin.com/qZePJdT5
And my phpinfo is here: http://pastebin.com/cAWuu8wr
Thanks.
We were seeing this exact issue with the Goolge public DNS servers. We fixed it by simply restarting PHP-FPM. This issue has been the topic of some twitter disucssions:
https://twitter.com/laravelphp/status/844181376224165890
However is does not seem to be DigitalOcean specific.
Rebooting server (linux) and changing nothing else fixed this.
Related
A web site is sending requests to a server with XMLHttpRequest and FormData object. Files are added to it. It works fine most of the time but sometimes, it fails with no message from server, no headers, nothing is received. The network monitor shows request headers but not response headers and I can't get any HTTP error code, it is empty !? If I retry this request multiple times, it succeed.
The problem seems to happen with Firefox (103.0b7), 102 and 101. I've also tried to reproduce with portable versions of Firefox 97, 100 and 101 but I can't.
I can't reproduce it with Vivaldi (5.3.2679.68) or Edge (103.0.1264.49).
I've checked the Apache and FPM logs.
FPM access log says : error 500
Apache access log says : error 400
Apache error log says : proxy_fcgi:error (103) Software connection abort: [client IP-Address:port] AH01075: Error dispatching request to : (reading input brigade), referer : sender-url (I've replaced real IP-Address:port and sender-url).
Here is the server configuration even if I don't think the problem is here :
$> php -v
PHP 7.4.28 (cli) (built: Feb 17 2022 16:17:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
$> apache2 -v
Server version: Apache/2.4.53 (Debian)
Server built: 2022-03-14T16:28:35
Is there something else I can check to find the problem ?
[EDIT]
It seems to be resolved with Firefox versions 104 and later. On 103 the bug was still there.
I've installed PHP on my windows 10 computer, and started IIS.
But when I browse to http://localhost/phpinfo.hml the page is completely blank.
And if I look at the file view in IIS, it seems that it's not aware that the file exists.
I've verified that the phpinfo.html file is in the right place:
ls -l C:\inetpub\wwwroot\phpinfo.html
Directory: C:\inetpub\wwwroot
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 7/16/2020 8:54 AM 72 phpinfo.html
And has the right contents:
PS C:\inetpub\wwwroot> cat .\phpinfo.html
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
PHP is installed:
php --version
PHP 7.4.1 (cli) (built: Dec 17 2019 19:23:59) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
I gave my windows user full access to that directory. What am I doing wrong? How can I get this working?
If you want to show phpinfo page, you need to change phpinfo.html to phpinfo.php.
And you also need to handle PHP requests by using IIS Manager, you can set this in Handler Mappings.
More information about how to configure IIS to Handle PHP Requests you can refer to this link: Configure IIS to Handle PHP Requests
We have a strange issue that has started happening on one of our servers.
after about 24 hours an initial script that has a require_once in it suddenly starts failing.
it may not fail every time. as we use the same script to load images it may be that 3 or 4 random images would fail every time the page loads.
I've added the script and the error although there is no errors until about 24 hours after php fpm has started so please don't try and debug the code
gareth#app8 /var/log/nginx % php -v
PHP 7.4.3 (cli) (built: Feb 23 2020 07:24:28) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
gareth#app8 /var/log/nginx % nginx -v
nginx version: nginx/1.17.8
2020/03/05 04:24:38 [error] 37086#37086: *249519 FastCGI sent in stderr: "PHP message: PHP Fatal error: require_once(): Failed opening required '../system/bootstrap.php' (include_path='.:/usr/share/php') in /var/www/mindworks.co.uk/public_html/bootstrap.php on line 12" while reading response header from upstream, client: 162.158.89.232, server: mindworks.co.uk, request: "GET /$
<?php
/**
* must define URL_ROOT in here for resources
* to be loaded in correctly, this has moved out
* of Config.
*/
define('URL_ROOT', '/');
/**
* load the system's bootstrap.
*/
require_once '../system/bootstrap.php';
I have a script that check if the file exist on another server with get_headers. I've two servers on one server it works, on the other I get an empty response from get_headers.
my code:
$myurl='http://stackoverflow.com/';
$header = get_headers($myurl);
print_r($header);
php version
PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli) (built: Aug 6 2012 14:18:06)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
solution:
No sure what it was, my apache log was full of those errors
failed to open stream: php_network_getaddresses: getaddrinfo failed: System error
after a reboot it all went away and get_headers is working now.
Check if allow_url_fopen is on.
php --info | grep allow_url_fopen
I'm trying get the helloworld example for the Google Appengine PHP SDK working, but I can't seem to get the dev_appserver to even run. This is the command line I use and the error I get:
$ /opt/google-appengine-php/dev_appserver.py --php_executable_path=/usr/bin/php-cgi src
INFO 2013-06-14 02:50:09,070 sdk_update_checker.py:244] Checking for updates to the SDK.
INFO 2013-06-14 02:50:09,331 sdk_update_checker.py:260] Update check failed: HTTP Error 404: Not Found
INFO 2013-06-14 02:50:09,458 api_server.py:138] Starting API server at: http://localhost:39069
INFO 2013-06-14 02:50:09,647 dispatcher.py:164] Starting server "default" running at: http://localhost:8080
INFO 2013-06-14 02:50:09,650 admin_server.py:117] Starting admin server at: http://localhost:8000
ERROR 2013-06-14 02:50:09,717 php_runtime.py:199] The PHP runtime is not available because: No input file specified.
The output from php-cgi -v is:
PHP 5.4.16 (cgi-fcgi) (built: Jun 7 2013 05:55:42)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
The output from whereis php-cgi is:
php-cgi: /usr/bin/php-cgi
I looked at the php_runtime.py file but I can't even find the string No input file specified so I'm stumped!
Anyone have any idea what the problem is?
EDIT: I just tried running fgrep -r 'No input file specified' * in the App Engine directory and nothing shows up!!!
EDIT 2: It seems the message No input file specified comes from the PHP interpreter, no the App Engine SDK. But I still have no idea why?! the app.yaml and helloworld.php files are in the same directory and are copied from the tutorial page.
It seems the problem is the way I installed my system. My /home directory is actually a symbolic-link to /var/home (I have two partitions: / and /var) but PHP has a directive to limit where it loads files from, open_basedir. By default it includes /home but PHP resolves symlinks so all my files were coming from /var/home and /var (or anything below) are not included.
So the solution is to replace /home with /var/home in the open_basedir directive of my /etc/php/php.ini file.
EDIT: Also, since I installed the AppEngine PHP SDK in /opt/google-appengine-php I had to add that directory to open_basedir too.