Symptoms
-
A WordPress instance site shows 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'
-
There is a
.user.ini
file at thepublic_html
root directory folder 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.
Resolution
-
Edit the
.user.ini
file to comment the sentence that starts with "auto_prepend_file
" by adding a semicolon (";") before like:; Wordfence WAF
; auto_prepend_file = '/var/www/vhosts/example.com/public_html/wordfence-waf.php'
Command Line solution:
-
Connect to the server via SSH.
-
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