How to Install IonCube on Ubuntu 16.04
How to Install IonCube on Ubuntu 16.04
An important part of shifting security left in the SDLC is using tools that allow devs to automate the process of secure coding. Read on to learn about one such tool.
Join the DZone community and get the full member experience.Join For Free
Ioncube is used to encrypt PHP code. There are two main benefits.
One is the fast loading speeds of your website. The other one is preventing others from stealing the source code by converting your PHP into byte-code.
Today in this article, we will see how to install IonCube on Ubuntu 16.04.
You should have configured your server with the initial server setup procedures.
Identify the Server Configuration
We are going to choose the IonCube version which matches the operating system, and our current PHP version of the system.
You have to also check whether it is a 32 bit or 64-bit operating system.
To get all this information, we are going write to a small PHP script.
First, we are going to create a file called info.php.
$ sudo nano /var/www/html/info.php
Enter the following code in the nano editor:
The above code will return the server information when you access it through a web browser, so you can see your system information.
For that, enter: http://your_server_IP_address_or_domain_name/php.info
You will see the following information.
According to the PHP information:
Server: Ubuntu 16.04 server.
Bit: 64 bit.
Web server: Apache 2.
Now, you got the server configuration and your next step is to download and install IonCube.
Downloading the Suitable Version of IonCube
Use wget to download the file.
$ wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
The download will take some time.
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz --2017-07-20 06:17:42-- http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz Resolving downloads3.ioncube.com (downloads3.ioncube.com)... 184.108.40.206 Connecting to downloads3.ioncube.com (downloads3.ioncube.com)|220.127.116.11|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 8947796 (8.5M) [application/x-tar] Saving to: ‘ioncube_loaders_lin_x86-64.tar.gz’ ioncube_loaders_lin 100%[===================>] 8.53M 1019KB/s in 34s 2017-07-20 06:18:26 (258 KB/s) - ‘ioncube_loaders_lin_x86-64.tar.gz’ saved [8947796/8947796]
Then, extract the file:
$ tar xvfz ioncube_loaders_lin_x86-64.tar.gz
The extracted file will be stored in a folder with the name 'ioncube.' The extraction process will be finished in seconds.
ioncube/ ioncube/ioncube_loader_lin_5.0.so ioncube/ioncube_loader_lin_4.3.so ioncube/ioncube_loader_lin_7.0_ts.so ioncube/ioncube_loader_lin_4.2.so ioncube/ioncube_loader_lin_5.6.so ioncube/ioncube_loader_lin_5.3.so ioncube/ioncube_loader_lin_5.5_ts.so ioncube/ioncube_loader_lin_5.4.so ioncube/loader-wizard.php ioncube/ioncube_loader_lin_4.3_ts.so ioncube/ioncube_loader_lin_5.5.so ioncube/LICENSE.txt ioncube/USER-GUIDE.pdf ioncube/ioncube_loader_lin_5.4_ts.so ioncube/ioncube_loader_lin_7.0.so ioncube/ioncube_loader_lin_5.3_ts.so ioncube/ioncube_loader_lin_4.4.so ioncube/ioncube_loader_lin_4.4_ts.so ioncube/ioncube_loader_lin_5.2.so ioncube/USER-GUIDE.txt ioncube/ioncube_loader_lin_4.1.so ioncube/README.txt ioncube/ioncube_loader_lin_5.1_ts.so ioncube/ioncube_loader_lin_5.0_ts.so ioncube/ioncube_loader_lin_5.1.so ioncube/ioncube_loader_lin_5.6_ts.so ioncube/ioncube_loader_lin_5.2_ts.so
The file will contain multiple files for many PHP versions.
Here, we have PHP 7.0 installed on our system. So that you have to copy the ioncube_loader_lin_7.0.so file to a PHP extension directory.
To find where the extension path is located on your server, search the extension_dir in the php.info page.
The extension directory is located at /usr/lib/php/20151012.
So, we have to copy the file here.
$ sudo cp ioncube/ioncube_loader_lin_7.0.so /usr/lib/php/20151012/
Here, the PHP has to load the extension, for that you have to add the extension in the PHP configuration file.
The adding part can be done through the php.ini file.
In order for the extension to load first, you have to create a file which will load before all the extensions.
The new configuration can be created at a specific location which will be mentioned on the php.info page. To find that out, go to http://domain_or_ip.
When the page opens, search for “Scan this dir for additional.ini files.”
So, we have to create 00-ioncube.ini file at /etc/php/7.0/apache2/conf.d.
The 00 in front of the file gives preference to the file so that it will be executed first before to the execution of any other file.
Now, create the file using nano editor.
$ sudo nano /etc/php/7.0/apache2/conf.d/00-ioncube.ini
Add the following code in the file.
zend_extension = "/usr/lib/php/20151012/ioncube_loader_lin_7.0.so"
Save the file and close it.
In order to make the changes work, you have to reload the web server.
Here, we are using Apache as the webserver. Let us reload Apache.
$ sudo systemctl restart apache2.service
Note: Nginx users have to use the below command to restart the Nginx.
$ sudo systemctl restart nginx
Then, restart the php-fpm also.
$ sudo systemctl restart php7.0-fpm.service
Now, IonCube should work. In the next step, we will verify it.
Verify IonCube Installation
Reload the php.info page. And you can see the IonCube details above the php.ini notification above the Apache configuration detail.
Once you have verified that, you have to remove three files to save memory and for security reasons.
First, remove info.php:
$ sudo rm /var/www/html/info.php
Then remove the IonCube files.
$ sudo rm ioncube_loaders_lin_x86-64.tar.gz $ sudo rm -rf ioncube_loaders_lin_x86-64
That’s all. You are done with the process.
IonCube has been installed on your system.
The process is easy and everyone can benefit from it.
Opinions expressed by DZone contributors are their own.