Ioncube Loaders are a piece of software that is used to protect the underlying code in PHP applications. Its aim is to obscure the real code so end users can’t steal it. It’s commonly used in licensed software like WHMCS and the popular WHMCS Support Module to name a few. Ioncube was very popular years ago but as companies move to a SaaS (Software as a service) module it’s becoming less relevant. In this guide, we are going to install Ioncube Loaders to an Ubuntu NVMe VPS. The install process is the same for all Linux versions so you can use this guide to Install Ioncube Loaders in CentOS, Debian, Ubuntu, RHEL and of course, AlmaLinux.
Install Ioncube Loaders
- Installing in cPanel? See Install Ioncube Loaders In cPanel
Right. Let’s install Ioncube in Linux. As of writing this, the latest PHP version that can be used with IonCube Loaders is PHP 8.2. On the Ioncube website they list several files which you can use to manually install Ioncube Loaders. However, the easiest way to install Ioncube Loaders is using the Wizard.
The files need to be placed in a publicly accessible directory. Navigate to that directory and use WGET to download the Wizzard.
wget https://www.ioncube.com/loader-wizard/loader-wizard.zip && tar xvf loader-wizzard.zip && unzip loader-wizzard.zip
Inside your directory, you will now notice a new folder called ioncube. Chown the files so the web server can read them
chown -R www-data:www-data /path/to/www.domain.com/files
Next, access the Ioncube Loader Wizard in your browser.
https://domain.com/ioncube/loader-wizzard.php
The Ioncube Wizard will scan the server and tell you the files you need to use.
So next download either the .tar.gz or .zip file to your server.
cd /tmp && wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.zip &&
unzip ioncube_loaders_lin_x86-64.zip
Located in the /tmp/ioncube
folder is the list of Ioncube Loaders for all PHP versions. We are using PHP 8.1 so we are only interested in ioncube_loader_lin_8.1.so file. Copy that to the location specified in the Wizard. In our case, we copy it to /usr/local/lsws/lsphp81/lib/php/20210902
cp /tmp/ioncube/ioncube_loader_lin_8.1.so /usr/local/lsws/lsphp81/lib/php/20210902
Finally, place a 00-ioncube.ini file in the second path displayed in the wizard. /usr/local/lsws/lsphp81/etc/php/8.1/mods-available/
in our case.
nano /usr/local/lsws/lsphp81/etc/php/8.1/mods-available/00-ioncube.ini
Inside this file. Place the below code block. This file is also displayed in the Wizard to download. Always download the file and double-check the correct line to place here.
zend_extension = /usr/local/lsws/lsphp81/lib/php/20210902/ioncube_loader_lin_8.1.so
Restart the webserver and check your PHP -v page to ensure Ioncube Loaders are now installed in PHP.
systemctl restart lsws && php -v
PHP 8.1.27 (cli) (built: Dec 21 2023 10:30:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.27, Copyright (c) Zend Technologies
with the ionCube PHP Loader v13.0.2, Copyright (c) 2002-2023, by ionCube Ltd.
with Zend OPcache v8.1.27, Copyright (c), by Zend Technologies
Manually Install Ioncube Loaders
It’s always best to use the Wizard above because that provides the correct paths to place files. However, if you want to complete this manually the instructions are below.
cd /tmp
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar -zxvf ioncube_loaders_lin_x86-64.tar.gz
cd ioncube
ls -lhr
So now you are seeing a list of files in the Ioncube download. We need to copy the correct file for our PHP version. Note the file names. We are using PHP 8.2 so we are only interested in the ioncube_loader_lin_8.2.so file.
Next, we need to learn where to copy the loader too. Issue the command below to find where the extensions are kept.
php -i | grep extension_dir
The returned information will display the path to the extensions folder. In our server. The extensions folder is located at /usr/lib/php/20190902. So now we copy the correct loader to that folder.
cp /tmp/ioncube/ioncube_loader_lin_8.2.so /usr/lib/php/20190902
And finally. We need to tell PHP that we have installed Ioncube Loaders and that it should use them. We do this by appending the location of Ioncube loaders. But first, find all of your PHP.ini files that are in use. You can do this with php –ini.
php --ini
Configuration File (php.ini) Path: /etc/php/8.2/cli
Loaded Configuration File: /etc/php/8.2/cli/php.ini
Scan for additional .ini files in: /etc/php/8.2/cli/conf.d
Additional .ini files parsed: /etc/php/8.2/cli/conf.d/10-mysqlnd.ini,
So in our server, we need to append the below to the /etc/php/8.2/cli/php.ini file. Then restart Apache.
nano /etc/php/8.2/cli/php.ini>
# append to bottom of file
zend_extension = /usr/lib/php/20190902/ioncube_loader_lin_8.2.so
Finally, when you issue php -v you should notice that the loaders are now loaded into PHP. Note that there may also be another php.ini file located at /etc/php/8.2/apache2/php.ini. So ensure you also add the line above to that php.ini file. That’s it. Ioncube Loaders have now been installed in your Linux Server and you can use applications encoded with Ioncube.