Articles in this section

A WordPress instance on Plesk fails with error 500: PHP Fatal error: Failed opening required '/var/www/vhosts/example.com/public_html/wordfence-waf.php'

Plesk for Linux kb: technical

Symptoms

  • A WordPress website example.com is inaccessible with HTTP error 500.
  • The website has been migrated from cPanel.
  • The following errors can be found under Domains > example.com > Logs:

    Warning 203.0.113.2 mod_fcgid: stderr: PHP Fatal error: Failed opening required '/var/www/vhosts/example.com/public_html/wordfence-waf.php'

    or

    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/example.com/public_html/wordfence-waf.php' (include_path='.:/opt/plesk/php/7.1/share/pear') in Unknown on line 0', referer: http://www.example.com

  • There is a .user.ini file at the public_html folder of example.com with the following instruction:

    ; Wordfence WAF
    auto_prepend_file = '/var/www/vhosts/example.com/public_html/wordfence-waf.php'

Cause

WordFence plugin was removed from the WordPress instance but some leftovers of this still exist and cause the site errors.

Resolution

  1. Log into Plesk
  2. Go to Domains > example.com > Files
  3. Navigate to public_html and open the .user.ini file
  4. Comment out the line starting with auto_prepend_file by adding a semicolon (";") like:

    ; Wordfence WAF
    ; auto_prepend_file = '/var/www/vhosts/example.com/public_html/wordfence-waf.php'

  5. Clic Save
Command Line solution:
  1. Connect to the server via SSH.
  2. Run the following command while replacing example.com by the WordPress domain name:

    # sed -i -e '/wordpress-waf.php/s/auto_prepend_file/;auto_prepend_file/' /var/www/vhosts/example.com/public_html/.user.ini

Was this article helpful?

Comments

2 comments
Date Votes
  • This fixed the problem. I corrected the path. This website was working up until last night. An update must have happened that broke the site. How did that path get reset to the default? In my case the website in question is under a subscription so the path wouldn't be the default /var/www/vhosts/{website.com}/ but rather /var/www/vhosts/{subscription}/{website.com}? Everything in the curly braces is to obscure the actual names to protect the innocent.) Could this be a problem with the wp-toolkit changing the .user.ini and we found a bug in the toolkit in that it doesn't seem to be aware of subscriptions?

    0
  • Thank you for your comment. If I understand correctly the path you are referring is the one for “auto_prepend_file” which was noticed to be updated automatically on the example you share. This article references to the cases where WordFence is no longer present on the instance but the .user.ini file remains. Please consider submitting a Support case to review this further and verify the potential bug you describe although the file mentioned on this article is handled by the plugin it might require further investigation to check if wp-toolkit modifies this somehow.

    0

Please sign in to leave a comment.