I am trying to install nginx and php-fpm following this guide on a FreeBSD 11.1 system on a raspberrypi-B+.

Everything behaves as described in the guide up to point 14, which involves opening a php file with information about the system by running


At this point, when I open http://localhost/info.php, nginx times out while waiting for an answer from php-fpm. The following message appears in the nginx log:

[error] 876#100128: *1 upstream timed out (60: Operation timed out) while reading response header from upstream, client:, server: localhost, request: "GET /info.php HTTP/1.0", upstream: "fastcgi://", host: "localhost"

In /usr/local/etc/nginx/nginx.conf I have a section for php files:

location ~ \.php$ {
    root           /usr/local/www/nginx;
    fastcgi_index  index.php;
    fastcgi_read_timeout 180;
    fastcgi_param  SCRIPT_FILENAME $request_filename;    
    include        fastcgi_params;

and in /usr/local/etc/php-fpm.d/www.conf I have the line:

listen =

So I checked if nginx can connect to php-fpm:

$ sudo sockstat -4 -6| grep nginx


www      nginx      876   3  tcp4
www      nginx      876   6  tcp4   *:80                  *:*
www      nginx      876   9  tcp4
root     nginx      875   6  tcp4   *:80                  *:*

where you can see the incoming connection requesting the page and the outgoing connection to port 9000 (fastcgi).

Looking at php-fpm with

$ sudo  sockstat -4 -6| grep php-fpm


www      php-fpm    935   0  tcp4        *:*
www      php-fpm    934   0  tcp4        *:*
www      php-fpm    934   4  tcp4
root     php-fpm    933   8  tcp4        *:*

where you can see the incoming connection.

So nginx seems to be connected to php-fpm but nothing happens. In htop I can see a master process php-fpm with two worker child processes, one of which is taking almost 100% of the CPU time. After a while nginx times out and the worker php-fpm stays at 100% and does not release the socket. The php-fpm log file (/var/log/php-fpm.log) does not show any error:

[24-Dec-2017 23:09:21] NOTICE: fpm is running, pid 933
[24-Dec-2017 23:09:21] NOTICE: ready to handle connections

Pid 933 is the master. No log output from the child processes.

So this is what I have found and I do not have any idea of what I should look at next. Do you have any suggestions?


The problem seems to be related to PHP-7.1. I have installed an older version (PHP-5.6) and the problem disappeared. I leave the question open in case the problem is related to some PHP-7 specific configuration.

  • Please post your PHP-FPM configuration file, just the parts that define the listener. Check if it's listening on port 9000 or on a Unix socket - you want the former to match your Nginx configuration. – Tim Dec 25 '17 at 1:13
  • Even if you have php-fpm running, you need to have the nginx config to sent php scripts to port 9000. Do you have this? Something like: location ~\.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(.*)$; if (-f $request_filename) { fastcgi_pass; } – Gmck Dec 25 '17 at 4:27
  • @Gmck: Thanks for the hints. I have added the relevant parts from the configuration files to the question. Also, the output of sockstat seems to confirm that the two processes can connect, so I suppose the problem is somewhere else, but I may be wrong. – Giorgio Dec 25 '17 at 10:08
  • @Tim: I have edited the question. – Giorgio Dec 25 '17 at 10:08
  • If your PHP-FPM worker process is using 100% CPU, then there is something wrong with its settings or the actual software. It seems that it receives the request, but then something happens that makes it enter a busy loop and never return an answer. – Tero Kilkanen Dec 25 '17 at 11:42

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.