Cyberpanel Multi Wordpress website Wordfence Firewall Set up

#1
Hi guy, I'm using Openlitespeed with Cyberpanel. I have a problems is I use 2 wordpress website on my VPS. And I dont know how to setting up php.ini for Wordfence. I follow this thread but only the first website work. 2nd was down. I need to change 2nd website to another php version. How to fix this problems.
https://forum.openlitespeed.org/threads/ols-wordpress-wordfence-config.3855/

Hi @chaselifetech

I use Cyberpanel with OpenLiteSpeed, too. And I also host multiple domains on my VPSes. All of them are using Wordfence. This is how I did it:
First of all, install Wordfence on all of your websites on the same VPS. After that, let it generate all of Wordfence files on your sites by following the usual Wordfence firewall's guidance by a couple of clicks..

Now, here comes the fun part:
1. Login to your Cyberpanel. Under Server -- PHP -- click on Edit PHP Configs.
2. You'll have 2 options: Basic & Advanced. Choose Advanced.
3. Select your PHP version. Right now, all my websites are using PHP 7.3. So, I choose that one.
4. Under:
Code:
; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
Insert:
Code:
auto_prepend_file = "/home/1stdomain.tld/public_html/loader.php"
Replace 1stdomain.tld with the domain that you want to use. After that, click "Save Changes"
....
Now, create loader.php file in your first domain which contains:
Code:
<?php
// Prepend the firewall for 1stdomain.tld:
if (strpos($_SERVER['SCRIPT_FILENAME'], '/home/1stdomain.tld/public_html') !== false) {
// Load the firewall:
require('/home/1stdomain.tld/public_html/wordfence-waf.php');

// Prepend the firewall for 2nddomain.tld:
} elseif (strpos($_SERVER['SCRIPT_FILENAME'], '/home/2nddomain.tld/public_html') !== false) {
// Load the firewall:
require('/home/2nddomain.tld/public_html/wordfence-waf.php');

// Prepend the firewall for 3rddomain.tld:
} elseif (strpos($_SERVER['SCRIPT_FILENAME'], '/home/3rddomain.tld/public_html') !== false) {
// Load the firewall:
require('/home/3rddomain.tld/public_html/wordfence-waf.php');

}
You can modify it to as many domains as you want. You can use your favorite text editor to edit that. For convenience, I used WinSCP to add and edit the file. After you've done editing, save it and change the file permission. With WinSCP, you just right click on loader.php and choose properties and then change Group & Owner to your site 1 user.

If you're comfortable using command line, you can use this:
Code:
ls -l /home
to find out your site user.

And then:
Code:
chown -R usrsite1:usrsite1 loader.php
Replace usrsite1 with your user on site 1.

If you edited the php.ini manually by using command, you need to restart OpenLiteSpeed. Do so by entering this command:
Code:
/usr/local/lsws/bin/lswsctrl restart
Done. Check your sites. There should be no more warning from Wordfence.

It's almost 3 am in my time, and English is not my first language. I hope what I wrote can help you.
 

Pong

Administrator
#2
I need to change 2nd website to another php version
After you login to cyberpanel, you should be able to change PHP version fo your domain. If not, show me screen and error.

By the way, if you have wordpress multisite setup which use the same doc_root. You can not do so. only one PHP allow for that case.
 
Top