Verified and Tested 09/30/15

Introduction

In this How-To, we will walk you through the install and configuration of ionCube on CentOS 7.1. The ionCube Loader provides additional security to your PHP files or websites; it’s a PHP module that encrypts basic PHP language making it more secure.

Installing ionCube on CentOS 7

To get started, log in to your CentOS 7.1 server via SSH or Console. If you are using the Atlantic.Net cloud hosting service, note that they are setup with minimal installations to avoid having unnecessary packages from being installed and never used. If some software packages that you’re used to using aren’t installed by default, feel free to install them as needed.

Let us download wget so we can simplify this tutorial.

sudo yum install wget

Let’s make sure that your server is fully up-to-date so we can complete the preparation.

sudo yum update

Downloading ionCube on CentOS 7

For this tutorial, I will be downloading the 64-bit version as my system is a 64bit server.  We will use the wget command to get the ionCube file from their website with the following command:

wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

Extract the ionCube file with the following command:

tar xfz ioncube_loaders_lin_x86-64.tar.gz

Alternatively, if you have a 32-bit system you can download the 32-bit version from the site with the following command:

wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz

Extract the 32-bit ionCube file with the following command:

tar xfz ioncube_loaders_lin_x86.tar.gz

Configuring ionCube on CentOS 7

In order to configure ionCube correctly, we need to know what version of PHP is running on the server. The PHP version will tell us which extension to load. Let’s verify the version PHP by running the following comment:

php -v

The output of the command shows that the system we’re deploying on is running PHP 5.4.

PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27)
Copyright (c) 1997-2013 The PHP Group

Next we need to locate where PHP is loading extensions; this can be done by running the below command and looking

php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules

Note: not all versions of PHP use the same location. On my test environment, the module location is /usr/lib64/php/modules, but on other servers it may be different.

Now that we know the version of PHP and have located the PHP modules folder, we can work to make sure that the correct ionCube module is available. Run the ls (list) command on the ioncube folder to get that information.

ls ioncube
ioncube_loader_lin_4.1.so     ioncube_loader_lin_4.4_ts.so  ioncube_loader_lin_5.2.so     ioncube_loader_lin_5.4_ts.so  
ioncube_loader_lin_4.2.so     ioncube_loader_lin_5.0.so     ioncube_loader_lin_5.2_ts.so  ioncube_loader_lin_5.5.so     
ioncube_loader_lin_4.3.so     ioncube_loader_lin_5.0_ts.so  ioncube_loader_lin_5.3.so     ioncube_loader_lin_5.5_ts.so  
ioncube_loader_lin_4.3_ts.so  ioncube_loader_lin_5.1.so     ioncube_loader_lin_5.3_ts.so  ioncube_loader_lin_5.6.so     
ioncube_loader_lin_4.4.so     ioncube_loader_lin_5.1_ts.so  ioncube_loader_lin_5.4.so     ioncube_loader_lin_5.6_ts.so

Since the installed version of PHP is 5.4, let’s copy the 5.4 version of the ionCube Loader to the PHP extensions directory we identified earlier:

cp ioncube/ioncube_loader_lin_5.4.so /usr/lib64/php/modules

Once the file has been copied to the extensions directory, we need to make sure that the PHP configuration file is updated to use the correct extension.

Using your favorite text editor open the php.ini file with the following command:

nano /etc/php.ini

At the very top of the file  let’s add the following line:

zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_5.4.so

Restart Apache so that the web server can load all the configuration changes that were made with the following command:

service httpd restart

Restart PHP-FPM (if installed)  so that the PHP can accept all the configuration changes that were made with the following command:

service php-fpm restart

Testing ionCube on CentOS 7

Now that PHP has been updated to use the ionCube PHP Loader, we need to double check that everything is working. This can be done in one of two ways.

First, you can run the php -v command again. If everything is installed correctly, you will notice that a message stating ionCube Loader is enabled:

php -v
PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.0.18, Copyright (c) 2002-2015, by ionCube Ltd.

The second one is by opening up your browser and going to http://your-server’s-address/info.php. You should get a PHP Version page with the image below.(Note: if you followed the LAMP tutorial that was referenced at the beginning of this how-to, an info.php file was already created).

This is the Zend Engine confirmation that ionCube Loader is currently enabled.

This is the Zend Engine confirmation that ionCube Loader is currently enabled.

What Next?

Congratulations! You now have successfully installed and configured ionCube Loader on CentOS 7.1. Thank you for following along and feel free to check back with us for further updates.