P
P
poimanoo2017-06-18 23:20:20
PHP
poimanoo, 2017-06-18 23:20:20

Nginx + php-fpm: why file not found? why No input file specified?

Hello.
I installed nginx on one host and php-fpm on the second. I want to achieve php execution on the second.
There are many places on the Internet that recommend setting the value of the cgi.fix_pathinfo=0 parameter in the php.ini file. If I do this, then when I request the page XXXXX.com/index.php I get a page with the text No input file specified , and the following is written to the log:

[error] 31572#31572: *1 FastCGI sent in stderr: "Unable to open primary script: /var/www/XXXXX.com/html/index.php (No such file or directory)" while reading response header from upstream, client: XXX.XXX.X.XX, server: XXXXX.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://XXX.XXX.XXX.XX:9000", host: XXXXX.com ".

If I set the value of this parameter to cgi.fix_pathinfo=1 , then when I request the page XXXXX.com/index.php I get the message file not found .
The sadness is that I have not been able to understand for a day how to treat either the first or the second. Hope someone can point out what is wrong.
The server code is below:
server {
  listen 443;
  ssl on;
  ssl_certificate /etc/ssl/XXXXX.com.crt;
  ssl_certificate_key /etc/ssl/XXXXX.com.key; 

  root /var/www/XXXXX.com/html;

  index index.html index.htm index.nginx-debian.html;

  server_name XXXXX.com www.XXXXX.com;

  location / {
    try_files $uri $uri/ =404;
  }

  location ~ \.php$ { 

            fastcgi_index index.php;
      fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
            fastcgi_pass XXX.XXX.XXX.XX:9000; #ip второго хоста(на котором php установлен)
      fastcgi_read_timeout 300; 
        } 

        location ~ /\.ht { 
            deny all; 
        }
}

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        server_name XXXXX.com www.XXXXX.com;
        return 301 https://XXXXX.com;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2017-06-19
@BorisKorobkov

The file /var/www/XXXXX.com/html/index.php must be on the second host, not the first.
In my opinion, it's easier to keep Nginx/PHP together on the same host.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question