auto_prepend_file in order to work correctly, as it allows the Wordfence WAF to load before WordPress, rather than afterward.
By default, the following directive in .htaccess is used to load WordFence, but this directive does not work in OpenLiteSpeed.
php_value auto_prepend_file '/home/example.com/public_html/wordfence-waf.php'
Luckily, there are alternatives. There are three different methods you can use with OpenLiteSpeed:
Method 1: WebAdmin (recommended):
Log in to the WebAdmin Console, navigate to Vhost Configuration > General and add the following line to php.ini Override, like shown in the screenshot below (change the path to match your actual path, if necessary):
php_value auto_prepend_file /home/example.com/public_html/wordfence-waf.php
Restart OpenLiteSpeed, and kill lsphp process if you are using PHP Detached Mode.
Check the phpinfo page, and you will see that this file is appended:
Method 2: Direct Edit
(usually located in
/usr/local/lsws/lsphpXX/etc/php/X.X/litespeed/php.ini), and add the following line:
auto_prepend_file = /home/example.com/public_html/wordfence-waf.php
This will be in effect for all sites that are using this PHP version. If there are multiple sites on your server, and you only want this configuration to apply to one of them, use Method 3 instead.
Method 3: By Virtual Host
Follow this guide to set up php.ini override, then follow Method 2 above to add the append file. Doing it this way allows the configuration to only apply to this site. It will not affect other sites on same server.