1

I have an nginx (in a Debian docker container) with this config for a Symfony app:

location ~ ^/api/(app|app_dev|config)\.php(/|$) {
    root /var/www/backend/web/;
    fastcgi_split_path_info ^/api/(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    fastcgi_param HTTPS off;
}

The location is recognized correctly, the SCRIPT_FILENAME points to the correct file. However, I get

recv() not ready (11: Resource temporarily unavailable)

in the nginx debug logs whenever I make a request. nginx responds with 504 Gateway Time-out.

There are idle fpm workers which get remade the moment I kill them, seems right to me since it's a pool. I tried using 127.0.0.1:9000 instead of the socket, but same thing. This is most likely not a question of load or memory, there's plenty of RAM available and I'm only making a single request, CPU load is 0.0.

How can I make FPM work with nginx?

Tim-Erwin
  • 115
  • 1
  • 5

1 Answers1

0

The obvious things I see in your configuration snippet are stray / characters:

    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

Notice that in the sample configuration, this is absent.

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

You also have a stray trailing / in the root directive.

    root /var/www/backend/web/;

I expected to see:

    root /var/www/backend/web;

With your existing configuration, SCRIPT_FILENAME gets set to, e.g. /var/www/backend/web///api/config.php. This really shouldn't matter, but it's possible you've run into a scenario where it does matter.


If that doesn't solve it, start looking at your application code.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • Thanks for looking into this. I first didn't have those `/` characters. When I remove them I get `Primary script unknown`. The `/` at the end of `root` gets removed automatically so it doesn't make a difference. But without the `/` in `SCRIPT_FILENAME` I get `SCRIPT_FILENAME: /var/www/backend/webapp_dev.php` for a request like `http://localhost/api/app_dev.php/bla/`, which is lacking a `/`. – Tim-Erwin Jul 17 '18 at 06:04
  • The application works in general, it's in production use already. Just trying to set up a new Docker deployment. – Tim-Erwin Jul 17 '18 at 06:05
  • I think you need to configure `fastcgi_split_path_info` then. – Michael Hampton Jul 17 '18 at 17:04
  • I did (see the code). I'll investigate in the direction you suggested and look at my application code again. – Tim-Erwin Jul 17 '18 at 18:00
  • My config was actually ok, turns out the database host was not right which took PHP so long to figure out, that nginx decided to call it unavailable. So "start looking at your application code." was the correct answer thanks. – Tim-Erwin Jul 23 '18 at 12:56