PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 28, 2022

[FIXED] How do I resolve "PHP Fatal error: Unknown: Failed opening required"

 January 28, 2022     .htaccess, php, ubuntu-16.04, ubuntu-server, wordpress     No comments   

Issue

I have two sites on a LAMP stack. One (Site1) uses WordPress with Wordfence, and it works perfectly fine. The second website (Site2) only runs a simple index.php file on it:

<?php
echo "Testing";
?>

However, it shows HTTP ERROR 500 with the error log as below.

[Thu Dec 22 16:23:44.774993 2016] [:error] [pid 56607] [client xxx:27253] PHP Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Thu Dec 22 16:23:44.775042 2016] [:error] [pid 56607] [client xxx:27253] PHP Fatal error:  Unknown: Failed opening required '/var/www/site1/public_html/public/wordfence-waf.php' (include_path='.:/usr/share/php') in Unknown on line 0

Site1 and Site2 have nothing to do with each other, and they are located in separate folders. I am not sure what's happening. Please advise.

.htaccess file on Site1

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# Wordfence WAF
<IfModule mod_php7.c>
        php_value auto_prepend_file '/var/www/site1/public_html/public/wordfence-waf.php'
</IfModule>
<Files ".user.ini">
<IfModule mod_authz_core.c>
        Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
</IfModule>
</Files>

# END Wordfence WAF

Solution

Thanks for @EdCottrell. I finally found an answer for that.

First, I debug to find where the php.ini locates by create a info.php on the working site.

<? php phpinfo(); ?>

Then, I find if there is any value on auto_prepend_file =. If yes, delete it.

Then I open the site1.conf file and add the auto_prepend_file line instead of the one from .htaccess

<Directory "/path/to/folder">
    php_value auto_prepend_file /absolute/path/to/apache-prepend.php
</Directory>

After restarting the Apache server, everything works again!

sudo systemctl restart apache2


Answered By - Dale Nguyen
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing