简体   繁体   中英

PHP Error "Unknown: failed to open stream... in Unknown on line 0..." when editing php files

I get a strange php error:

2022-03-14 10:52:19: (mod_fastcgi.c.421) FastCGI-stderr: PHP message: 
PHP Warning:  Unknown: failed to open stream: 
No such file or directory in Unknown on line 0
PHP message: PHP Fatal error:  Unknown: Failed opening required 
'var/www/vhosts/webdev/sites/test/hello.php'
(include_path='.') in Unknown on line 0

Long explanation:

  1. I create a file hello.php in my webroot, having the content:

    <?php echo("hello"); ?>

  2. I run this file in a browser, all is fine, it shows "hello"

  3. Now I edit this file so the content now is:

    <?php echo("hello"); echo("world"); ?>

  4. I run this edited file in a browser => The error is shown

  5. I reload the page (F5 or ctrl-R) => all is working fine now

In other words: Whenever I edit a php file and try to run it in a browser, I get this error message. After reloading the page it works!

That is the real strange thing, after reloading everything is working fine!!!

My config

  • a local raspberry pi running raspbian

  • webserver: lighttpd (standard install from repo)

  • php7.3-fpm (standard install from repo)

  • all file permissions in my web dev folder are 775, all files are www-data:www-data owned

  • NO selinux running (like in other answers suggested)

  • the php.ini is pretty much untouched, some options:

     auto_prepend_file = auto_append_file = include_path = "." 
  • there are no other hidden config files in the folder

With html files there are no problems. So it must be a php-fpm problem. I am out of ideas now. It might be a very easy fix, but I am not a Pro.

Any ideas how to fix this?

In the error log, the path doesn't start with a slash "/"

var/www/vhosts/webdev/sites/test/hello.php

which indicates a misconfiguration in lighttpd/fastcgi configuration

Fixing the path should make everything work correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM