IonCube is a commercial software suite that consists of a PHP encoder, package foundry, bundler, a real-time site intrusion detection and error reporting application as well as 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. In this article, we will show you how to install and configure the ionCube Loader with PHP in CentOS 7.
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 LAMP server
For the following tutorial, we will need to set up a web server. In this tutorial, we will assume that you have LAMP set up on your CentOS 7 server. Go 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 operating systems 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:
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:
- For 32 bit:
Once the download is complete, you can use the tar command to unzip the downloaded file. Once this is done, you can run the ls command to list the complete ionCube Loader files.
tar -zxvf ioncube_loaders_lin_x86*
Step 3: Install ionCube Loader
There are different ioncube loader files for various PHP versions. For this reason, you should pay close attention to select the right ioncube loader for your installed PHP version on your server. To check your PHP version, run the command:
You will see the PHP version displayed on the terminal. For the purpose of 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.
Find the following files:
ioncube_loader_lin_7.2_ts.so and ioncube_loader_lin_7.2.so
We will be using the ‘ioncubeloaderlin_7.2.so’ file because it matches our PHP version. If you have a different version of PHP installed on your server you will have to use the appropriate file.
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:
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
To test if ionCube loader is now installed and properly configured on your server, check your PHP version once more. You should be able to see a message indicating that PHP is installed and configured with the ionCube loader extension (status should be enabled).
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 will come across any kind of problems, don’t hesitate to contact us via the dedicated comment section below.