IonCube is a commercial software suite consisting of a PHP encoder, package foundry, bundler, a real-time site intrusion detection and error reporting application, and a loader. IonCube is a PHP module extension that loads encrypted PHP files and speeds up web pages that are being displayed.

IonCube is often required for a lot of PHP-based applications. It is mostly used in commercial software applications to protect their source code and prevent it from being visible. This article will show you how to install and configure the ionCube Loader with PHP in CentOS 7.  

Prerequisites

Before we get started, we will need to have the following:

  • Must have a running webserver with PHP installed (Nginx or Apache)
  • Access to the root user account or an account with sudo privileges
  • Basic understanding of Linux commands

Step 1: Install the LAMP server

We will need to set up a web server for the following tutorial. In this tutorial, we will assume that you have LAMP set up on your CentOS 7 server. Check out our article on how to install LAMP on CentOS and proceed to step 2.

Note that you can install any kind of web server which contains PHP.

Step 2: Download IonCube Loader

There are two different downloader files for 32-bit and 64-bit operating systems. Therefore, first, we will check what operating system we have. Enter the following command to find exactly how your system is running:

uname –a

Output:

Linux 1gbits.com 4.15.0-1.el7.elrepo.x86_64 #1 SMP Sun Jan 28 20:45:20 EST 2018 x86_64 x86_64 x86_64 GNU/Linux

The above output clearly states that the system is running on 64-bit architecture.

Now that we know the architecture of our system, we will go ahead and download the relevant ionCube Loader files.

  • For 64-bit:

cd /tmp

wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

  • For 32-bit:

cd /tmp

wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz

Once the download is complete, you can use the tar command to unzip the downloaded file. Once done, you can run the ls command to list the complete ionCube Loader files.

tar -zxvf ioncube_loaders_lin_x86*

cd ioncube/

ls -l

Step 3: Install IonCube Loader

There are different IonCube loader files for various PHP versions. For this reason, you should pay close attention to selecting the right IonCube loader for your installed PHP version on your server. To check your PHP version, run the command:

php -v

You will see the PHP version displayed on the terminal. For this tutorial, we will assume the PHP version is 7.2. Note yours down and find the location of the extension directory for the PHP version; it is where the IonCube loader file will be installed.

ls ioncube

Find the following files:

ioncube_loader_lin_7.2_ts.so and ioncube_loader_lin_7.2.so

We will use the ‘ioncubeloaderlin_7.2.so’ file because it matches our PHP version. You must use the appropriate file if you have a different version of PHP installed on your server.

To find out the location of the extension directory, run the following command.

php -i | grep extension_dir

extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules

Note that the path may vary from system to system!

Next we need to copy ioncube loader for our PHP 7.2 version to the extension directory (/usr/lib64/php/modules).

cp ioncube/ioncube_loader_lin_7.2.so /usr/lib64/php/modules

Note: Make sure to replace the PHP version and extension directory in the above command according to your system configuration.

Step 4: Configure ionCube Loader

In this step, we will make some configurations for ionCube Loader. Open the php.ini file using the nano text editor:

nano /etc/php.ini

In the opened file, add the following:

zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_7.2.so

Now, save and exit the file. Everything is set in place. You should restart the Apache or Nginx web server for the ionCube Loader changes to come into effect.

  • For Apache webserver:

systemctl restart httpd

  • For Nginx +PHP-FPM web server:

systemctl restart nginx

systemctl restart php-fpm

Step 5: Testing the ionCube Loader

Check your PHP version to test if the IonCube loader is installed and properly configured on your server. You should be able to see a message indicating that PHP is installed and configured with the ionCube loader extension (status should be enabled).

php -v

Conclusions

Congratulations on setting up the ionCube Loader on your CentOS 7 server. ionCube loader is a PHP extension for loading files secured and encoded with a PHP encoder. We hope that everything worked fine while following this guide. If you have any problems, don’t hesitate to contact us via the dedicated comment section below.

People also read: