1

I installed arch linux and nginx in a chroot (archlinux wiki). Thats working.

Now I want to get fastcgi running. I set the php-fpm socket to 127.0.0.1:9000 to reach it from the chroot (/srv/http).

While the html files are printed successfully the php-files are "not found". In the nginx-log I found this:

FastCGI sent in stderr: "primary script unknown" while reading response header from upstream, client: 10.211.55.2, server: localhost, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000:, host: "10.211.55.6".

So I think the php-fpm does not found the file, because the path is absolute in the nginx chroot and it searches in the real root. So I added, yes very ugly, the following to my settings, but there is no change of the result. How can I debug it, or better, find a clean solution?

location ~ \.php$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    include       fastcgi_params;
    fastcgi_param SCRIPT_FILENAME  /srv/http$document_root$fastcgi_script_name
}

Tanks a lot.

fvosberg
  • 677
  • 10
  • 30
  • Nobody an idea. One to debug is enough. Is it possible to print the variables to the shell or to a file? Thanks – fvosberg Jun 28 '13 at 19:29
  • I ran into the same problem. I'm gonna work on figuring out a solution... – Ray Perea Oct 13 '13 at 00:03
  • @fvosberg Did the comments or my answer solve your issue? If the answer helped, you can say thanks by up voting and/or checking as answered. – James Risner Oct 17 '22 at 16:20

1 Answers1

0

FPM is looking in the wrong place.

Change your php-fpm configuration to add additional information on your access log file. My server is configured this way:

[www]
access.format = "%t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

A sample line of the result of that configuration from my server:

07/Sep/2022:19:23:03 -0400 "GET index.php?q=/login&" 200 /nginx/ech11/public/index.php 23.787 2048 21.67%

In order, these options I use in my access logs:

  • %t is the current time (07/Sep/2022:19:23:03).
  • %m is the method (GET).
  • %r is the request URI (index.php?q=/login).
  • %Q is the glue between %q and %r (&).
  • %q is the query string. (empty in my example).
  • %s is the status (200).
  • %f is the script (/nginx/ech11/public/index.php)
  • %d is the duration µs (23.787).
  • %M is the memory (2048).
  • %C is the %CPU (21.67%).

That should inform you which settings to alter in the nginx.conf to enable fpm to find the index.php file.

Some other options you can use:

%e  fastcgi env
%l  content length
%n  pool name
%o  header output
%p  PID
%T  time
James Risner
  • 5,451
  • 11
  • 25
  • 47