Error 28105 # 0: * 1 FastCGI sent to stderr: "Primary script unknown" while reading response header from upstream

I am unable to configure correctly Nginx

with php-fpm

. When I receive any PHP script, I get the Nginx error 404 Not found

in the browser:

File not found.

      

In my php-fpm logs I get:

172.17.42.1 -  28/Apr/2015:09:15:15 +0000 "GET /index.php" 404

      

for any php script call and in the Nginx logs I get:

[error] 28105#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.168.66.66:9000", host: "localhost"

      

My Nginx vitualhost config:

server {
  listen 80;

  root /var/www/html;
  index index.html;

  server_name localhost;

  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
  }

  location ~* \.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    127.168.66.66:9000;
    #fastcgi_pass    unix:/var/run/php5-fpm.sock;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
  }
}

      

I had a reverse php-fpm Docker image from the official php repository that is being executed:

docker run -it -p 127.168.66.66:9000:9000 php:fpm

      

The command docker ps

shows the following information:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                          NAMES
dbf9f7d1c6f9        php:fpm             "php-fpm"           8 seconds ago       Up 7 seconds        127.168.66.66:9000->9000/tcp   serene_curie 

      

What's wrong with my configuration?

PS Any static files (css, js, images) work on Nginx.

+3


source to share


1 answer


You also need to exchange files with the docker container php:fpm

. The answer is to run the docker php:fpm

image with volume too:



docker run -it -p 127.168.66.66:9000:9000 -v /var/www/html/:/var/www/html/ php:fpm

      

+6


source







All Articles