Enable WordFence¶
WordFence requires 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:
- WebAdmin (recommended)
- Direct edit
- By virtual host
WebAdmin¶
Log in to the WebAdmin Console, navigate to Vhost Configuration > General and add the following line to php.ini Override, like so (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 the wordfence-waf
file is listed as the Local Value for the auto_prepend_file
Directive.
Direct edit¶
Directly edit php.ini
(usually located in /usr/local/lsws/lsphpXX/etc/php.ini
or /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 the virtual host method instead.
By virtual host¶
Follow this guide to set up php.ini override, then use the direct edit method 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.