nginx php fpm file not found

nginx + php-fpm = File not found

When i try accessing info.php I get a File not found. error.

I tried some Tutorials to no avail.

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

8 Answers 8

If that info.php is in /var/www, then it’s wrong to instruct fast_cgi to look for

Use the same root for html and php. Also, root and index parameters should be outside a particular location except for very specific uses.

needless to say, you still need to make sure your php-fpm service is listening at port 7777. Common case is to have it listening at port 9000.

If you checked every thing and it’s correct configured, then there is last point i got:

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

Nginx & Symlinks

Note, if root /var/www; is a symlink, change it to root /var/www/; otherwise nginx won’t go past the symlink and you’ll get a File not found error

Documentation for variables above:

file path for the current request, based on the root or alias directives, and the request URI

root or alias directive’s value for the current request

request URI or, if a URI ends with a slash, request URI with an index file name configured by the fastcgi_index directive appended to it. This variable can be used to set the SCRIPT_FILENAME and PATH_TRANSLATED parameters that determine the script name in PHP. For example, for the “/info/” request with the following directives

Источник

Docker-compose Nginx php-fpm file not found

I have a simple docker-compose config with php-fpm and nginx, and I can’t see any php file. When I go to localhost, it shows File Not Found.

I tried everything I could find on the net, but everything I have tried has failed. It works fine for html, but not for php files. Seems to be a path issue, or something like that.

I come across this error when I docker-compose logs :

Here’s my docker-compose:

Then my dockerfile for php:

my default.conf for nginx:

pwd of the main folder is:

The file hierarchy is:

The whole folder is chmod 777

Any idea would be greatly appreciated. I’m sure there is something I didn’t get. Thanks in advance.

6 Answers 6

Here is how you can find the problem

The problem in the most of case

If your docker-compose.yml contains like this:

You have to set this in «site.conf» in nginx container:

I was missing this line in the volume of PHP section of docker-compose:

here’s what the docker-compose should look like:

The absolute root (here «/usr/share/nginx/html») in the nginx default.conf file had to be set as well in the php part of docker-compose (was only under nginx before)

In my case the volumes: of php and nginx were pointing a the correct (and hence the same) directory. But in my nginx config there was a NGINX_SERVER_ROOT: pointing the wrong way.

So make sure you double check all volumes and root directory settings. Some are easy to overlook.

And in docker-compose.yml:

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

I had the same problem but this wasn’t solved by any of this answer here:

So I could fix it by:

Источник

File Not Found when running PHP with Nginx

Recently I installed the latest version of Nginx and looks like I’m having hard time running PHP with it.

Here is the configuration file I’m using for the domain:

Here is the error I’m getting on the error log file:

16 Answers 16

Try another *fastcgi_param* something like

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

I had the «file not found» problem, so I moved the «root» definition up into the «server» bracket to provide a default value for all the locations. You can always override this by giving any location it’s own root.

Alternatively, I could have defined root in both my locations.

Probably it’s too late to answer but a couple things since this is a really annoying error. Following solution worked on Mac OS X Yosemite.

The include with fast cgi params should go above that line.

All your directories down to the PHP file you’re executing (including that file too) should have a+x permissions, e.g.

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

I had been having the same issues, And during my tests, I have faced both problems:

And I found out that, in my case:

I had to mount volumes for my public folders both on the Nginx volumes and the PHP volumes.

If it’s mounted in Nginx and is not mounted in PHP, it will give: «File not found«

Examples (Will show «File not found error»):

If it’s mounted in PHP and is not mounted in Nginx, it will give a 404 Page Not Found error.

Example (Will throw 404 Page Not Found Error):

And this would work just fine (mounting on both sides) (Assuming everything else is well configured and you’re facing the same problem as me):

I hope this helps someone, And if anyone knows more about this please let me know, Thanks!

I just spent like 40 minutes trying to debug a non-working /status with:

It just produced «File not found» error, while the actual scripts (that are found on the filesystem) worked just fine.

Turned out, I had a couple of orphaned processes of php5-fpm. After I killed everything and restarted php5-fpm cleanly, it just went back to normal.

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

In my case the PHP-script itself returned 404 code. Had nothing to do with nginx.

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

In my case, it was because the permissions on the root web directory were not set correctly. To do this, you need to be in the parent folder when you run this in terminal:

This will chmod all files in your html folder, which is not recommended for production for security reasons, but should let you see the files in that folder, to be sure that isn’t the issue while troubleshooting.

The error message “Primary script unknown or in your case is file not found.” is almost always related to a wrongly set in line SCRIPT_FILENAME in the Nginx fastcgi_param directive (Quote from https://serverfault.com/a/517327/560171).

In my case, I use Nginx 1.17.10 and my configuration is:

Источник

Arch Linux

You are not logged in.

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

Hello, I just updated packages and now php-fpm seems not working at all. It gives the errors «File not found» in the browser, and «primary script unknown while reading response header» in the log.

I checked all the bhosts, but they are just fine. I suspect there is some change due to the recent 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)

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

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.

FWIW, I just upgraded my server and have no issues with php-fpm on nginx.

Last edited by Trilby (2019-11-30 14:59:37)

Online

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

access.log:
2019/11/30 16:16:29 [error] 9842#9842: *3 FastCGI sent in stderr: «Primary script unknown» while 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»

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.

Источник

Nginx + php5-fpm = «File not found»

I’ve hit a wall whilst setting up a site using nginx / fpm. The page displays «File not found», and this appears in the nginx error.log:

I’m new to both nginx and fpm, and that error message means nothing to me (even the google machine hasn’t helped!). Can anyone shed any light onto what could be happening?

7 Answers 7

You should have a location section to handle PHP requests configured similarly to this:

(The extra try_files resolves a security vulnerability which could allow arbitrary files to be executed as PHP.)

In addition, your root should be defined in the server section of the configuration file, not the location section. This is one of the most common nginx misconfigurations.

nginx php fpm file not found. Смотреть фото nginx php fpm file not found. Смотреть картинку nginx php fpm file not found. Картинка про nginx php fpm file not found. Фото nginx php fpm file not found

This is a note for passenger installs.

I just installed nginx from source via passenger which caused a problem with php5-fpm. The default nginx.conf makes use of the problem described by Michael Hampton. The solution is to remove the blok around the root and index directives, so:

Furthermore the php block is incorrectly set up. See Michael Hamptons answer for the correct way to it.

An additional note could be that if php5-fpm is set up to use sockets point the fastcgi_pass parameter in the php block in nginx.conf to the socket setup in /etc/php5/fpm/pool.d/www.conf.

I Just had this problem in a new version of nginx. (config taken from an older version)

What I had to do was place the include fastcgi_params; above my custom SCRIPT_FILENAME like this:

As the SCRIPT_FILENAME was being overwritten.

If you’re using aliases in your location blocks, an unhandled 404 error can also exhibit this behavior. You can see this if the page displayed in the browser is the simple text «File not found» as opposed to the prettier formatted (centered) nginx 404 page. Essentially, it’s really saying the 404 page can’t be found.

about line 149, change php user && user group

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *