wordpress - Primary script unknown

L
  • 3 Aug '23
Hi guys.

This must be trivial - I certainly thought - but it confused 
the hell out of me:
I'm doing - what many must have done before me - this:
...
   root         /var/www/ale.xyx_wordpress;

   location / {
     try_files $uri $uri/ /index.php?$args;
   }
   location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
     expires max;
     log_not_found off;
   }
   location = /favicon.ico {
     log_not_found off;
     access_log off;
   }
   location = /robots.txt {
     allow all;
     log_not_found off;
     access_log off;
   }
   index index.php index.html index.htm;

   location ~ \.(php|phar)(/.*)?$ {
     fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;

     fastcgi_intercept_errors on;
     fastcgi_index  index.php;
     include        fastcgi_params;
     fastcgi_param  SCRIPT_FILENAME 
$document_root$fastcgi_script_name;
     #fastcgi_param  PATH_INFO $fastcgi_path_info;
     fastcgi_pass   php-fpm;
   }

# upstream

upstream php-fpm {
         server unix:/run/php-fpm/www.sock;
}

when I go to web root, Nginx logs:
...
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
copy: "SERVER_PORT"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
var: "443"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "SERVER_PORT: 443"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
copy: "SERVER_NAME"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
var: "ale.xyz"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "SERVER_NAME: ale.xyz"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
copy: "REDIRECT_STATUS"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
copy: "200"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "REDIRECT_STATUS: 200"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
copy: "SCRIPT_FILENAME"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
var: "/var/www/ale.xyx_wordpress"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 http script 
var: "/index.php"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "SCRIPT_FILENAME: /var/www/ale.xyx_wordpress/index.php"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_HOST: ale.xyz"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_CACHE_CONTROL: max-age=0"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_UPGRADE_INSECURE_REQUESTS: 1"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_USER_AGENT: Mozilla/5.0 (X11; Linux x86_64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 
Safari/537.36"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_ACCEPT: 
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_SEC_GPC: 1"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_ACCEPT_LANGUAGE: en-GB,en;q=0.9"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_SEC_FETCH_SITE: none"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_SEC_FETCH_MODE: navigate"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_SEC_FETCH_USER: ?1"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_SEC_FETCH_DEST: document"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_ACCEPT_ENCODING: gzip, deflate, br"
2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi 
param: "HTTP_COOKIE: 
wordpress_test_cookie=WP%20Cookie%20check; 
wp-settings-time-1=1686766849; 
PHPSESSID=caa771c30b66d7bf6c86ab15b132479f"
...
and eventually:
...
2023/08/03 13:50:24 [error] 1112963#1112963: *27 FastCGI 
sent in stderr: "Primary script unknown" while reading 
response header from upstream, client: 10.3.9.144, server: 
ale.xyz, request: "GET / HTTP/2.0", upstream: 
"fastcgi://unix:/run/php-fpm/www.sock:", host: "ale.xyz"
...

This is pretty much vanilla-default on Centos 9, those 
configs are - what am I missing?
I hope it's be trivial for some people here and I could get 
some pointers.
many thanks, L.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20230803/64253122/attachment.htm>
F
  • 5 Aug '23
On Thu, Aug 03, 2023 at 02:00:11PM +0200, lejeczek via nginx wrote:

Hi there,

> 2023/08/03 13:50:24 [debug] 1112963#1112963: *27 fastcgi param:
> "SCRIPT_FILENAME: /var/www/ale.xyx_wordpress/index.php"

> 2023/08/03 13:50:24 [error] 1112963#1112963: *27 FastCGI sent in stderr:
> "Primary script unknown" while reading response header from upstream,
> client: 10.3.9.144, server: ale.xyz, request: "GET / HTTP/2.0", upstream:
> "fastcgi://unix:/run/php-fpm/www.sock:", host: "ale.xyz"

> This is pretty much vanilla-default on Centos 9, those configs are - what am
> I missing?

"Primary script unknown" is a message from the fastcgi server saying
that it is unable to access the file that it has been asked to use.

Usually, that filename comes from a specific one of the SCRIPT_FILENAME
values it receives (if it receives more than one).

Your fastcgi server might log more somewhere about what it thinks it
was doing. But can you check:

can the user that the fastcgi service is running as, read the file
/var/www/ale.xyx_wordpress/index.php from the perspective of the fastcgi
service?

That is -- do directory permissions towards that file and file permissions
on that file allow that user/group to read? Does the file exist at
that path name, if the fastcgi service is running in a chroot or other
confined context? Do selinux or other access control mechanisms allow
the fastcgi service to read the file?

Some other (less likely?) possibilities include -- does your nginx send
more than one value for SCRIPT_FILENAME; and if so, is your fastcgi server
trying to use a different one? Does your fastcgi server actually use
SCRIPT_FILENAME, or does it use some other param or combination of params?

Cheers,

    f
-- 
Francis Daly        francis at daoine.org