I’m currently trying to configure a WordPress Multisite using NGINX. The NGINX config test passes:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
But I simply get a File Not Found.
page when I load the site. From my config:
http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; include conf.d/*.conf; map $http_upgrade $connection_upgrade { default "upgrade"; } server { listen 80 default_server; access_log /var/log/nginx/access.log main; client_header_timeout 60; client_body_timeout 60; keepalive_timeout 60; gzip off; gzip_comp_level 4; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; server_name <my-domain>.com ; access_log /var/log/nginx/gnbwpms.access.log; error_log /var/log/nginx/gnbwpms.error.log debug; index index.php; if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^(/[^/]+)?(/wp-.*) $2 last; rewrite ^(/[^/]+)?(/.*.php) $2 last; } location / { try_files $uri $uri/ /index.php?$args ; } location ~ .php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php-fpm/www.sock; fastcgi_index index.php; } location ~* ^.+.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; } location = /robots.txt { access_log off; log_not_found off; } location ~ /. { deny all; access_log off; log_not_found off; } } }
And from my nginx error.log
:
2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 01 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 07 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 00 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 01 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 00 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 16 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 02 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 00 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record length: 22 2022/01/04 14:44:43 [error] 8368#8368: *552 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: <client IP>, server: <my-domain>.com, request: "GET / HTTP/1.1", upstream: " fastcgi://unix:/var/run/php-fpm/www.sock:", host: "<server IP>" 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 01 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 06 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 00 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 01 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 00 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 51 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 07 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record byte: 00 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi record length: 81 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi parser: 0 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi header: "Status: 404 Not Found" 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi parser: 0 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi header: "Content-type: text/html; charset=UTF-8" 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi parser: 1 2022/01/04 14:44:43 [debug] 8368#8368: *552 http fastcgi header done 2022/01/04 14:44:43 [debug] 8368#8368: *552 HTTP/1.1 404 Not Found
My docroot is /var/www/html
and the logs seem to show requests are being sent to the right place:
2022/01/04 14:44:43 [debug] 8368#8368: *552 trying to use file: "/index.php" "/var/www/html/index.php" 2022/01/04 14:44:43 [debug] 8368#8368: *552 try file uri: "/index.php" 2022/01/04 14:44:43 [debug] 8368#8368: *552 generic phase: 14
Not really sure where to go from here, so any help would be greatly appreciated.
Advertisement
Answer
Glad you managed to sort this. As mentioned in my comment, adding the following line to your server block resolved the issue:
SCRIPT_FILENAME $document_root$fastcgi_script_name