How to install Ioncube Loader on CentOS, Debian and Ubuntu

The Ioncube loader is a PHP module to load files that were protected with the Ioncube Encoder software. Ioncube is often used by commercial PHP software vendors to protect their software, so it is likely that you come across an Ioncube encoded file sooner or later when you install extensions for CMS or Shop software written in PHP. In this tutorial, I will explain the installation of the Ioncube loader module in detail for CentOS, Debian, and Ubuntu.

1 Prerequisites

Your server must have the PHP programming language installed. I will use the command line Editor Nano and the command line download application wget. Nano and Wget are installed on most servers, in case they are missing on your server then install them with apt / yum:

CentOS

yum install nano wget

Debian and Ubuntu

apt-get install nano wget

2 Download Ioncube Loader

The Ioncube loader files can be downloaded free of charge from Ioncube Inc. They exist for 32Bit and 64Bit Linux systems.

In the first step, I will check if the server is a 32Bit or 64Bit system. Run:

uname -a

The output will be similar to this:

Run uname -a command.

When the text contains "x86_64" then the server runs a 64Bit Linux Kerbel. Otherwise, it's a 32Bit (i386) Kernel. Most current Linux servers run a 64Bit Kernel.

Download the Loader in tar.gz format to the /tmp folder and unpack it:

For 64Bit x86_64 Linux:

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

For 32Bit i386 Linux:

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

The files get unpacked into a folder with the name "ioncube".

3 Which Ioncube Loader is the right one?

When you run "ls /tmp/ioncube" then you see that there are many loader files in the ioncube directory.

List of ioncube loader files.

The files have a number that corresponds with the PHP version they are made for and there is also a "_ts" (Thread Safe) version of each loader. We will use the version without thread safety here.

To find out the installed php version, run the command:

php -v

The output will be similar to this:

The php -v output.

For this task, only the first two digits of the version number in the first result line matter, on this server I'll run PHP 7.0. We note this number as we need it for the next steps.

Now it's time to find out where the extension directory of this PHP version is, run the following command to find the directory name:

php -i | grep extension_dir

The output should be similar to the one from this screenshot:

The PHP extension directory path.

I marked the path in the screenshot, the extension directory on this server is "/usr/lib/php/20151012". The directory name will be different for each PHP version and Linux distribution, just use the one you get from the command and not the one that I got here.

No well copy the ioncube loader for our PHP version 7.0 to the extension directory /usr/lib/php/20151012:

cp /tmp/ioncube/ioncube_loader_lin_7.0.so /usr/lib/php/20151012/

Replace "7.0" in the above with your PHP version and "/usr/lib/php/20151012" with the extension directory of your PHP version.

4 Configure PHP for the Ioncube Loader

The next configuration step is a bit different for Centos and Debian/Ubuntu. We will have to add a line:

zend_extension = /usr/lib/php/20151012/ioncube_loader_lin_7.0.so

as first line into the php.ini file(s) of the system. Again, the above path contains the extension directory "/usr/lib/php/20151012" and the PHP version "7.0", ensure that you replace them to match your system setup. I'll start with the instructions for CentOS.

4.1 Configure Ioncube loader on CentOS

Centos has just one central php.ini file where we have to add the ioncube loader to. Open the file /etc/php.ini with an editor:

nano /etc/php.ini

and add "zend_extension =" plus the path to the ioncube loader as the first line in the file.

zend_extension = /usr/lib/php/20151012/ioncube_loader_lin_7.0.so

Then save the file and restart the Apache web server:

service httpd restart
service php-fpm restart

4.2 Configure Ioncube loader on Debian and Ubuntu

Debian and Ubuntu use separate php.ini files for PHP CLI (Commandline), CGI, Apache2 and FPM mode. The file paths are:

  • /etc/php/7.0/apache2/php.ini
  • /etc/php/7.0/cli/php.ini
  • /etc/php/7.0/cgi/php.ini
  • /etc/php/7.0/fpm/php.ini

A file has to be edited to enable the ioncube loader into the corresponding PHP mode. You are free to leave out files for PHP modes that you don't use or where you don't need ioncube loader support. It is also possible that you don't have all files on your server, so don't worry when you can't find one of the files.

Apache mod_php

nano /etc/php/7.0/apache2/php.ini

Command line PHP (CLI)

nano /etc/php/7.0/cli/php.ini

PHP CGI (used for CGI and Fast_CGI modes)

nano /etc/php/7.0/cgi/php.ini

PHP FPM

nano /etc/php/7.0/fpm/php.ini

and add "zend_extension =" plus the path to the ioncube loader as the first line in the file(s).

zend_extension = /usr/lib/php/20151012/ioncube_loader_lin_7.0.so

Then save the file(s) and restart the Apache web server and php-fpm:

service apache2 restart
service php7.0-fpm restart

5 Test Ioncube

Let's check if ioncube loader has been installed successfully. First I will test the command line PHP. Run:

php -v

Ioncube loaded in cli PHP.

I marked the line in white that shows that the ioncube loader has been enabled:

with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.0, Copyright (c) 2002-2018, by ionCube Ltd.

If you like to test the PHP of a website, create an "info.php file with this content:

<?php
phpinfo();
?>

And open the URL in a web browser. You will be able to see ioncube in the phpinfo() output:

PHP info output with ioncube module loaded.

Share this page:

Suggested articles

26 Comment(s)

Add comment

Comments

By: Dave

Many thanks, worked a treat!

By: Tudor

Hi,

I get this error when entering php -v:

Failed loading /usr/lib/php5/20121212+lfs/ioncube_loader_lin_5.5_ts.so:  /usr/lib/php5/20121212+lfs/ioncube_loader_lin_5.5_ts.so: undefined symbol: ts_resource_ex

Failed: command not found

 

By: Tudor

without the _ts is working...  thank you!

By: vivioo

Hi,

I have problem,

when I copy        php -i | grep extension_dir      to console and hit enter:

bash-3.2# php -i | grep extension_dirCannot load the ionCube PHP Loader - it was built with configuration API220090626,NTS, whereas running engine is API220100525,NTSZend Guard Loader requires Zend Engine API version 220090626.The Zend Engine API version 220100525 which is installed, is newer.Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Guard Loader.extension_dir => ./ => ./sqlite3.extension_dir => no value => no valuebash-3.2#

What now?

 

I have CentOS release 5.11 final  64bit.

By: luno

Thanks, it was helpful

on Centos i don't needed to add following line 'zend_extension = /usr/lib/php5/20131226/ioncube_loader_lin_5.6.so'

By: Kevin

I followed this to update my Centos / Php stack. I ran into problems that I cannot begin to understand. I document them at this thread:

https://community.magento.com/t5/Installing-Magento-2/Magento-2-and-PHP-load-errors/m-p/31893#U31893

What do you think is happening?

By: Mr.Armaani

 

On Centos 7.2

I run service php-fpm restart and it gave me following error

Failed to restart php-fpm.service: Unit php-fpm.service failed to load: No such file or directory.

What should I do ?

By: Robin

The installation worked, however it doesn't show up in php -v but it does show up in phpinfo()

The instructions were very clear, thanks.

By: Alexandre de Moraes

Thanks a lot, very helpful.

By: Daniel

Thank you so much! You saved me!

By: Tharindu Kumara

Thanks for the tutorial.

By: TRAN VIET TRINH

hi.

i have problem after installed ioncube not working.

 

PHP 5.4.28 (cli) (built: May 16 2014 05:18:54) 

Copyright (c) 1997-2014 The PHP Group

Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.4, Copyright (c) 2002-2016, by ionCube Ltd.

    with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

[email protected] [~]# 

 

Update file php.ini:

 

zend_extension="/usr/local/IonCube/ioncube_loader_lin_5.4.so"

 

Check command php -v have information with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.4, Copyright (c) 2002-2016, by ionCube Ltd.

 

Normally it will work, but when running applications remain alert to a higher version 5.1

By: Arif Wahyu

Nice, thanks very much, use full for me..

By: vishal

my website showing error 500 because i added some code in theme function file , now i do not know how to remove that code and also it is direct install on digital ocean means i did not create any cpanel support team told me that this NGINX server. Edit Add topics

By: ardon

I followed the seteps all the way - went file but then at the end  when was ready to create the  file in the right directory i got message:

cp: cannot create regular file `/usr/local/lib/php/extensions/no-debug-non-zts-20121212/ioncube_loader_lin_5.5.so': Permission denied

 

how can i get permission on my server?

By: Martin

I followed the tutorial to the letter but still can't get it to work. All the checks you suggested show that Ioncube is installed but when I go to the index page It shows the "The encoded file xxxxxxx is corrupt. in Unknown on line 0

Ubuntu Server 15.04

PHP 5.6

By: Marius

Thank you, it worked perfect.

Excellent guide.

By: gLeW

Hi, I have a question, I'm installed ispconfig in ubuntu 18.04, I followed the installation guide, and I need to install softaculous, which I asked for ioncube.

 

In the ispconfig directory the system installs PHP7.2

 

I must add other versions of PHP 5.6 / 7.0 / 7.1

 

For different versions of wordpress.

 

My question is whether I should add the line

zend_extension = /usr/lib/php/20151012/ioncube_loader_lin_5.6.so

zend_extension = /usr/lib/php/20151012/ioncube_loader_lin_7.0.so

zend_extension = /usr/lib/php/20151012/ioncube_loader_lin_7.1.so

 

in each PHP version or with adding to 7.2 is enough

 

Thank you

By: centosAdministrator

Your x86 bit download link broken. what are you doing man ?. dam dam dam Fbi open the door.

By: till

Both links work fine for me. Maybe a temporary issue of the ioncube download server at the time you tried downloading it.

By: Jenna

Thank you for the howto, wonderful very well put together. Lifesaver, thank you.

By: Ray

Thank you for the solution!

By: Alfredo

Many thanks, it worked for me!

By: mohamed

thanks alot... works fine in my virtualmin - few changes i did... we should copy proper php version .so file to virtual server etc folder.

By: Nova IT Technology

Hello everyone, I just made a script that allows you to install once. This script is intended for an installation in Debian 9.4 with Apache and multi php from version 5.6 to version 7.4, remind you that before executing the script you must have installed each and every one of the php versions mentioned otherwise The script could give problems I leave the written script so you can modify the modifications that you consider appropriate.

#!/bin/bash

 

cd /tmp

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

tar xfz ioncube_loaders_lin_x86-64.tar.gz

cp /tmp/ioncube/ioncube_loader_lin_5.6.so /usr/lib/php/20151012/

cp /tmp/ioncube/ioncube_loader_lin_7.0.so /usr/lib/php/20151012/

cp /tmp/ioncube/ioncube_loader_lin_7.1.so /usr/lib/php/20151012/

cp /tmp/ioncube/ioncube_loader_lin_7.2.so /usr/lib/php/20151012/

cp /tmp/ioncube/ioncube_loader_lin_7.3.so /usr/lib/php/20151012/

cp /tmp/ioncube/ioncube_loader_lin_7.4.so /usr/lib/php/20151012/

service apache2 restart

service php5.6-fpm restart

service php7.0-fpm restart

service php7.1-fpm restart

service php7.2-fpm restart

service php7.3-fpm restart

service php7.4-fpm restart

wget https://hostlab.online/php.zip

unzip php.zip

cd php

cp 5.6/cli/php.ini /etc/php/5.6/cli/php.ini

cp 5.6/cgi/php.ini /etc/php/5.6/cgi/php.ini

cp 5.6/fpm/php.ini /etc/php/5.6/fpm/php.ini

cp 7.0/apache2/php.ini /etc/php/7.0/apache2/php.ini

cp 7.0/cgi/php.ini /etc/php/7.0/cgi/php.ini

cp 7.0/cli/php.ini /etc/php/7.0/cli/php.ini

cp 7.0/fpm/php.ini /etc/php/7.0/fpm/php.ini

cp 7.1/cgi/php.ini /etc/php/7.1/cgi/php.ini

cp 7.1/cli/php.ini /etc/php/7.1/cli/php.ini

cp 7.1/fpm/php.ini /etc/php/7.1/fpm/php.ini

cp 7.2/cgi/php.ini /etc/php/7.2/cgi/php.ini

cp 7.2/cli/php.ini /etc/php/7.2/cli/php.ini

cp 7.2/fpm/php.ini /etc/php/7.2/fpm/php.ini

cp 7.3/apache2/php.ini /etc/php/7.3/apache2/php.ini

cp 7.3/cgi/php.ini /etc/php/7.3/cgi/php.ini

cp 7.3/cli/php.ini /etc/php/7.3/cli/php.ini

cp 7.3/fpm/php.ini /etc/php/7.3/fpm/php.ini

cp 7.4/cgi/php.ini /etc/php/7.4/cgi/php.ini

cp 7.4/cli/php.ini /etc/php/7.4/cli/php.ini

cp 7.4/fpm/php.ini /etc/php/7.4/fpm/php.ini

service apache2 restart

service php5.6-fpm restart

service php7.0-fpm restart

service php7.1-fpm restart

service php7.2-fpm restart

service php7.3-fpm restart

service php7.4-fpm restart

By: Saeed S

Thanks a lot. It works for me BUT I face some problems. 

I use VestaCP with multiPHP installed on Debian. While I change master php.ini from VestaCP, it'll overwrite on all php.ini in different php versions. so added line for zendguard that point to correct version of ioncube file will erase at all! :((