Symptoms
- A WordPress website
example.comis 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.inifile at thepublic_htmlfolder ofexample.comwith 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
- Log into Plesk
- Go to Domains > example.com > Files
- Navigate to
public_htmland open the.user.inifile -
Comment out the line starting with
auto_prepend_fileby adding a semicolon (";") like:; Wordfence WAF
; auto_prepend_file = '/var/www/vhosts/example.com/public_html/wordfence-waf.php' - Clic Save
- Connect to the server via SSH.
-
Run the following command while replacing
example.comby 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
Comments
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?
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.
Please sign in to leave a comment.