How to get Ioncube working with Laravel Valet for WHMCS
ionCubeSystem configuration and setup:
- PHP 8.3. I will need to downgrade to PHP 8.2
- Download Ioncube from here: https://www.ioncube.com/loaders.php
First determine .ini
locations:
% php -i | grep .ini
Configuration File (php.ini) Path => /etc/php/8.3/cli
Loaded Configuration File => /etc/php/8.3/cli/php.ini
Scan this dir for additional .ini files => /etc/php/8.3/cli/conf.d
Additional .ini files parsed => /etc/php/8.3/cli/conf.d/10-mysqlnd.ini,
Here we note we have /etc/php/8.3/cli
and to be clear we'll want to also update /etc/php/8.3/fpm
.
Next to get more orientation, we output:
% cat /etc/php/8.3/cli/conf.d/10-mysqlnd.ini
; configuration for php mysql module
; priority=10
extension=mysqlnd.so
Where is mysqlnd.so
stored? We had to use Midnight Commander's search function, and find it here:
/usr/lib/php/20230831
This is there it gets weird. PHP has different directories for different versions. If we had to automate this script, we would probably have to hardcoded these directory names and figure out some kind of way to find it it exists.
Since we are running the wrong PHP version, we have to first downgrade:
apt install php8.2-fpm
doesn't work.
Let's install php8.2 on Linux Mint Xia:
apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
add-apt-repository ppa:ondrej/php
apt update
apt install php8.3-fpm
php -v
still shows version 8.3, let's activate version 8.2:
sudo update-alternatives --config php
Nice! Now let's fix Laravel Valet, simply do this as a non-sudo user:
valet install
Next, let's see which /usr/lib/php directories we have:
/usr/lib/php/20220829
Let's copy this file into there: ioncube_loader_lin_8.2.so
sudo cp /home/eugene/Downloads/ioncube/ioncube_loader_lin_8.2.so /usr/lib/php/20220829
Next, we can create the ini file:
echo 'zend_extension=ioncube_loader_lin_8.2.so' > /etc/php/8.2/cli/conf.d/10-ioncube.ini
echo 'zend_extension=ioncube_loader_lin_8.2.so' > /etc/php/8.2/fpm/conf.d/10-ioncube.ini
Finally, let's swap out the FPM version:
/etc/init.d/php8.3-fpm stop
/etc/init.d/php8.2-fpm start
Done! Now you can use WHMCS.
To be continued. This is a joke but with AI and bash automation it should be entirely possible to simplify the script. One would start with update alternatives to determine which versions of PHP is installed.
Errata:
#!/bin/bash
echo "⚠️ Stopping MariaDB..."
sudo systemctl stop mariadb
echo "✅ Starting MariaDB with --skip-grant-tables..."
sudo mysqld_safe --skip-grant-tables &
sleep 5
echo "🕒 Waiting for MariaDB to initialize..."
until mysqladmin ping &>/dev/null; do sleep 1; done
echo "🔧 Patching Grant_priv in mysql.global_priv..."
mysql -u root <<'EOF'
UPDATE mysql.global_priv
SET Priv = JSON_SET(Priv, '$.Grant_priv', true)
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
EOF
echo "🛑 Stopping MariaDB safe mode..."
sudo killall mysqld
sleep 5
echo "🚀 Restarting MariaDB normally..."
sudo systemctl start mariadb
echo "🎉 Done! You can now run your GRANT statements."