0% found this document useful (0 votes)
20 views

(SOLVED) Nginx + PHP-FPM - File Not Found, Primary Script Unknown - Networking, Server, and Protection - Arch Linux Forums

Uploaded by

kamarade
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

(SOLVED) Nginx + PHP-FPM - File Not Found, Primary Script Unknown - Networking, Server, and Protection - Arch Linux Forums

Uploaded by

kamarade
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection

unknown / Networking, Server, and Protection / Arch Linux Forums

Arch Linux
Home
Packages
Forums
Wiki
GitLab
Security
AUR
Download

Index Rules Search Register Login

You are not logged in. Topics: Active | Unanswered

Index » Networking, Server, and Protection


» [SOLVED] nginx + php-fpm - file not found, primary script unknown
Pages: 1 Topic closed

aquilarubra 2019-11-30 14:05:48 #1

Member Hello, I just updated packages and now php-fpm seems not working at all. It gives the errors "File not
From: Trieste, Italy found" in the browser, and "primary script unknown while reading response header" in the log.
Registered: 2018-11-24
I checked all the bhosts, but they are just fine. I suspect there is some change due to the recent
Posts: 89
security issue in php-fpm, but I cannot find a reference to fix the issue. Any idea?

Last edited by aquilarubra (2019-12-18 05:28:39)

Offline

https://bbs.archlinux.org/viewtopic.php?id=251050 1/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Trilby 2019-11-30 14:56:57 #2

Inspector Parrot Telling us you looked at the logs is useless, show us. Saying you checked the bhosts is the same.
Show us. Post logs, configs, etc, otherwise there is nothing we can offer here but sympathy (and even
that's not so likely). Is this a publicly available server? Give an example to a failing url.

https://bbs.archlinux.org/viewtopic.php?id=57855

FWIW, I just upgraded my server and have no issues with php-fpm on nginx.
Registered: 2011-11-29
Posts: 29,840 Last edited by Trilby (2019-11-30 14:59:37)
Website

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Online

2019-11-30 15:27:08 #3

aquilarubra
https://bbs.archlinux.org/viewtopic.php?id=251050 2/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Member Sample page: https://thelord.space/phpinfo.php


From: Trieste, Italy
access.log:
Registered: 2018-11-24
2019/11/30 16:16:29 [error] 9842#9842: *3 FastCGI sent in stderr: "Primary script unknown" while
Posts: 89
reading response header from upstream, client: 203.15.17.121, server: thelord.space, request: "GET
/phpinfo.php HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "thelord.space"

error.log:
151.95.156.135 - - [30/Nov/2019:16:16:29 +0100] "GET /phpinfo.php HTTP/2.0" 404 36 "-"
"Mozilla/5.0 (X11; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"

vhost:

location ~ \.php$ {
include fastcgi_params;
access_log /home/thelord.space/logs/access_log;
error_log /home/thelord.space/logs/error_log;
fastcgi_param SCRIPT_FILENAME /home/thelord.space/public_html$fastcgi_scrip
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}

I tried with the different settings for SCRIPT_FILENAME and none seems working. Previously, the
server was working with the full path: fastcgi_param SCRIPT_FILENAME
/home/thelord.space/public_html$fastcgi_script_name;

The php-fpm error log contains nothing (just the lines when I restart the server).

Obviously, the paths are correct and if I try with user "http", the files are accessible.

Html pages work and Perl works. Only php-fpm seems broken. Php-fpm server runs just fine.

Offline

2019-11-30 16:47:57 #4

Trilby
https://bbs.archlinux.org/viewtopic.php?id=251050 3/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Inspector Parrot The title of the thread I linked to is "Post complete logs/output/..."

aquilarubra wrote:
Obviously, the paths are correct and if I try with user "http", the files are accessible.

Registered: 2011-11-29 How/why is this obvious? What do you mean you try with user "http"? What do you actually do?
Posts: 29,840 What are (again) the actual commands and output?
Website
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Online

aquilarubra 2019-11-30 17:00:54 #5

Member ls /home/thelord.space/public_html/phpinfo.php shows it exists.


From: Trieste, Italy
If I "su http", I can run a command such as "php /home/thelord.space/public_html/phpinfo.php" and it
Registered: 2018-11-24
displays the expected output. So, the issue is when php goes through php-fpm.
Posts: 89
From my tests, $document_root might not be correct. But I have no clue how to debug that.

Offline

Trilby 2019-11-30 17:03:13 #6

Inspector Parrot Three posts in and you have still failed to provide any of the necessary context despite being explicitly
asked twice. I am unable (and now unwilling) to help. I'd encourage you to be much more
transparent and forthcoming if you want the next forum member who sees this thread to put in any
effort to help you.

Last edited by Trilby (2019-11-30 17:05:26)

Registered: 2011-11-29
Posts: 29,840 "UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Website

https://bbs.archlinux.org/viewtopic.php?id=251050 4/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Online

aquilarubra 2019-11-30 17:15:20 #7

Member You must be joking, I have answered every question and published my configuration and logs. Get
From: Trieste, Italy glasses.
Registered: 2018-11-24
Posts: 89

Offline

loqs 2019-11-30 17:29:30 #8

Member Is the system using php-fpm.service ?


Registered: 2014-03-06
Posts: 17,724

Offline

2019-11-30 17:34:32 #9

aquilarubra
https://bbs.archlinux.org/viewtopic.php?id=251050 5/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Member Yes. Sorry, I saw I omitted a few lines, as I am doing many tests.
From: Trieste, Italy
Host configuration:
Registered: 2018-11-24
Posts: 89
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";

fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
access_log /home/thelord.space/logs/access_log;
error_log /home/thelord.space/logs/error_log;

fastcgi_params file:

https://bbs.archlinux.org/viewtopic.php?id=251050 6/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;


fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;


fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param HTTPS $https if_not_empty;

# PHP only, required if PHP was built with --enable-force-cgi-redirect


fastcgi_param REDIRECT_STATUS 200;

#fastcgi_param REQUEST_SCHEME $scheme;

netstat -pnltu | grep 9000


tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 12417/php-fpm: mast

Last edited by aquilarubra (2019-11-30 17:36:40)

Offline

loqs 2019-11-30 17:57:16 #10

Member https://github.com/php/php-src/commit/4 … 45a203e37f


Registered: 2014-03-06 See the comment above ProtectHome=true
Posts: 17,724

Offline

https://bbs.archlinux.org/viewtopic.php?id=251050 7/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

aquilarubra 2019-11-30 18:18:34 #11

Member Thanks, that could be the case, as I have a folder outside /home that is partially working. But I edited
From: Trieste, Italy /etc/systemd/system/multi-user.target.wants/php-fpm.service setting ProtectHome=false, reloaded
Registered: 2018-11-24 services, restarted php-fpm, and I still get a 404/file not found error.
Posts: 89

Offline

aquilarubra 2019-11-30 18:31:36 #12

Member Ok, my mistake. It was solved!! Thank you so much.


From: Trieste, Italy
To recap, I did the following:
Registered: 2018-11-24
Posts: 89 1. Set ProtectHome=false in /etc/systemd/system/multi-user.target.wants/php-fpm.service
2. systemctl daemon-reload
3. systemctl restart nginx.service
4. systemctl restart php-fpm.service

Offline

aquilarubra 2019-11-30 19:41:55 #13

Member Question: I use nextcloud, which stores config files in /etc (/etc/webapps/nextcloud). Now it is not
From: Trieste, Italy working (after the update above). It gives the error "Cannot write into "config" directory!", despite the
Registered: 2018-11-24 directory is writeable.
Posts: 89
So, I suspect this depends on the setting ProtectSystem=full in /etc/systemd/system/multi-
user.target.wants/php-fpm.service

Any idea? I cannot find the options that can be used instead of "full".

Offline

2019-11-30 22:30:42 #14

Taijian
https://bbs.archlinux.org/viewtopic.php?id=251050 8/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Member OK seems that for nextcloud to keep working, we need both


Registered: 2016-04-10
Posts: 74 ProtectSystem=false
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_CHOWN

Otherwise php-fpm will not work.

Offline

loqs 2019-11-30 22:36:04 #15

Member See https://bugs.archlinux.org/task/64689 for nextcloud


Registered: 2014-03-06 CAP_CHOWN should not be needed with php-fpm 7.4.0-2
Posts: 17,724

Offline

Taijian 2019-11-30 23:59:55 #16

Member
loqs wrote:
Registered: 2016-04-10
Posts: 74 CAP_CHOWN should not be needed with php-fpm 7.4.0-2

Well, for me it complained about not being able to use chown on /run/php-fpm/php-fpm.sock without
that CAP. No idea why it needed to do that, though...

Offline

loqs 2019-12-01 00:13:05 #17

Member @Tainjan that was supposed to be fixed see https://bugs.archlinux.org/task/64683


Registered: 2014-03-06
Posts: 17,724

Offline

https://bbs.archlinux.org/viewtopic.php?id=251050 9/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Taijian 2019-12-01 00:14:02 #18

Member
loqs wrote:
Registered: 2016-04-10
Posts: 74 @Tainjan that was supposed to be fixed see https://bugs.archlinux.org/task/64683

Yeah, saw that now. I was still working with -1...

Offline

rafikfarhad 2019-12-18 14:52:56 #19

Member
aquilarubra wrote:
Registered: 2019-12-18
Posts: 3 Ok, my mistake. It was solved!! Thank you so much.

To recap, I did the following:

1. Set ProtectHome=false in /etc/systemd/system/multi-user.target.wants/php-fpm.service


2. systemctl daemon-reload
3. systemctl restart nginx.service
4. systemctl restart php-fpm.service

It did solve my problem for one site. But I'm getting the older error for my another site.

Offline

aquilarubra 2019-12-18 14:57:19 #20

Member I think I did a reboot in between.


From: Trieste, Italy Try also with ProtectSystem=false if one of your sites ends up in protected dirs.
Registered: 2018-11-24
Last edited by aquilarubra (2019-12-18 14:57:34)
Posts: 89

Offline

rafikfarhad 2019-12-22 13:51:17 #21

https://bbs.archlinux.org/viewtopic.php?id=251050 10/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Member Hey @aquilarubra,


Registered: 2019-12-18 I ran into another problem on my fresh installation. There is no
Posts: 3
/etc/systemd/system/multi-user.target.wants/php-fpm.service

file in my system.
Do you know what should I do now?

Offline

Trilby 2019-12-22 13:55:17 #22

Inspector Parrot That has nothing to do with this thread. That "file" is not provided by any package. Read the wiki on
using systemd to enable services.

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Registered: 2011-11-29
Posts: 29,840

Website

Online

rafikfarhad 2019-12-22 13:57:34 #23

Member Okay. Thank you very much.


Registered: 2019-12-18 Update 1: After enabling the service I found that folder and solved all my php-fpm problems there.
Posts: 3
Last edited by rafikfarhad (2019-12-22 14:05:45)

Offline

2019-12-22 15:33:40 #24

ewaller
https://bbs.archlinux.org/viewtopic.php?id=251050 11/12
09/07/2024 20:39 [SOLVED] nginx + php-fpm - file not found, primary script unknown / Networking, Server, and Protection / Arch Linux Forums

Administrator I am going to take this opportunity to close this old thread.

Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan
Turing
---
From: Pasadena, CA
How to Ask Questions the Smart Way
Registered: 2009-07-13
Posts: 19,986

Offline

Pages: 1 Topic closed

Index » Networking, Server, and Protection » [SOLVED] nginx + php-fpm - file not found, primary script unknown

Jump to Atom topic feed


Networking, Server, and Protection Go Powered by FluxBB

https://bbs.archlinux.org/viewtopic.php?id=251050 12/12

You might also like