How to resolve basic PHP-FPM unknown script using PHP-FPM and Dginx Nginx container?

My situation is this, I have two Docker containers:

  • Runs PHP-FPM on port 9000
  • Starts nginx and has PHP files (should the PHP-FPM container have access to the files?)

I keep getting the following error:

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.17.0.1, ser ver: _, request: "GET / HTTP/1.1", upstream: "fastcgi://172.17.0.2:9000", host: "172.17.0.3" 

I read here that it is "always related to the wrong set of SCRIPT_FILENAME in the nginx fastcgi_param directive".

The problem is that I do not know how to resolve it: -P

Configuration in container 2:

 server { listen 80 default_server; listen [::]:80 default_server; charset UTF-8; root /var/www/WordPress; index index.php index.html index.htm; server_name _; location / { try_files $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_pass 172.17.0.2:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /var/www/WordPress$fastcgi_script_name; # set headers add_header Cache-Control $cc; access_log off; expires $ex; } location ~* \.(js|css|svg|png|jpg|jpeg|gif|ico|eot|otf|ttf|woff)$ { add_header Access-Control-Allow-Origin *; add_header Cache-Control "public"; access_log off; log_not_found off; expires 1y; } location ~ /\.ht { deny all; } } 
+5
source share
2 answers

Change the root string to: root /var/www/WordPress/; for $fastcgi_script_name does not include /

0
source

I am not a nginx expert, but literally every instance of fastcgi_param SCRIPT_FILENAME in documents ends with $fastcgi_script_name , but your doesn’t.

0
source

Source: https://habr.com/ru/post/1261285/


All Articles