Running Encoded PHP Scripts with ionCube Loader

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

php ioncube loaderEncoding application sources is a common practice when it comes to protecting and/or licensing your application source code. Today we’ll talk about ionCube – one of the most popular and widely used solutions to prevent unauthorized use. Being PHP-oriented, ionCube provides two correlated tools  Encoder to compile PHP files into bytecode and Loader, which handles execution of such encoded files.

Whilst encoding shouldn’t be a big problem for the majority of developers, running such protected application can become a real point of concern for an average user, since often it requires the involvement of some auxiliary modules and libraries. Thus, to enable executing secured PHP source code without struggling on manual server configurations, the Jelastic Cloud provides dedicated lightweight ionCube Loader add-on for one-click installation.

So, log in to the Jelastic dashboard with your credentials and follow the instruction how to start operating encoded scripts in a matter of minutes.

ionCube Loader Add-On Installation

1. First of all, let’s ensure you have a proper PHP environment for processing your protected code with ionCube Loader.

For that, launch the environment topology wizard (by clicking either New Environment button at the dashboard top or Change environment topology icon next to the existing one) and switch to PHP tab.                 install ioncube loader

Here, application server choice depends only on your preferences (since both Apache and NGINX are supported), whilst a little more attention should be paid to the PHP versions list.

When selecting a particular engine, you need to consider it’s compatibility with ionCube Encoder version your scripts were initially converted with. As a general rule of thumb, encoded files could be processed on PHP versions that are equal to and higher than the source Encoder language, i.e. the full backward compatibility is provided. However, there are a few exceptions here:

  • currently, PHP 7.1 is not supported
  • with PHP 7.0 engine, only PHP 5.6-based files can be decoded
  • with PHP 5.6 and PHP 5.5, scripts of PHP 4 version can’t be decoded

To confirm the set parameters, click on Create or Apply (depending on whether you’ve created a new environment or adjusted the existing one).

2. Now, enter Jelastic Marketplace and switch to the section with pluggable Add-ons.install ioncube loader apache

Use search box to locate the one-click ionCube package and click Install.

Tip: The ionCube add-on sources are available within Jelastic JPS Collection, alongside with a number of other useful prepackaged solutions (all of them can be integrated through importing a manifest.jps link for the appropriate repository).

  3. In the opened installation window, specify the following details:

  • Environment name – environment the ionCube tool should be integrated to (encoded-app, in our case)
  • Nodes – target PHP application server for the add-on appliance (is fetched automatically upon selecting the environment)

install ioncube loader web server

Proceed with clicking on Install and wait a minute till this process is completed (you’ll also receive the appropriate email notification).

Note: During add-on appliance, the appropriate application server will be restarted that can cause a temporary downtime of your service (if any is already running inside). To avoid such outage, scale out a number of application servers beforehand so they can be restarted sequentially (with a predefined delay, 30 seconds by default).

Now, let’s check that the add-on is up and running properly.

Verification with ionCube Loader Wizard

The simplest way to ensure ionCube was successfully integrated is to review the php_info() server output – information on its status and version is listed in a separate block just under the main server configuration stats.

For more comprehensive check-up, you can launch a dedicated ionCube Loader Wizard within the appropriate container. It will test the proper Loader operability and provide you with a guidance in case any issue is detected. This step is optional and does not affect the actual ionCube operability. Thus, if you consider the additional check is needed, follow the instructions below:

1. Upload this archive via the Deployment Manager and initiate its deployment by selecting the destination environment (e.g. encoded-app). ioncube encoded php file

2. In the opened dialog, type some custom context to run the wizard at (so that it won’t intersect your main app location – e.g. ioncube) and click Deploy.ioncube loader php

Tip: Consider enabling Zero DownTime (ZDT) functionality to ensure availability of your project during subsequent redeployments. 

3. When the project is deployed, click Open in browser next to it.ioncube encoder

4. To launch the Wizard itself, append loader-wizard.php to the end of the opened tab URL. decode php ioncube

It will analyze and output the current ionCube add-on status, including the appropriate Loader version and PHP engine it runs at.  

5. For security reasons, it’s highly recommended to Delete the Wizard when it is no longer required – simply remove the server context it was handled at.php encryption ioncube

That’s it! Finally, let’s consider how to put the Loader add-on into action with the files that require decoding.

Running Encoded Application with ionCube

As a base for our encoded app example, we’ll use the default Jelastic Hello World project – take a quick look at a code snippet from its index.php file during conversion:

  • before encoding
<?php echo date(“Y”) ?>
  • after encoding

The compiled code contains several layers of encoding that can be interpreted and processed only by ionCube Loader. This will be done automatically by the extension we’ve installed – just deploy your PHP project to the destination environment as usual and Open it in browser.ioncube encrypted code

The application is up and running, so it means the Loader has successfully processed all protected files.ioncube loader

At this point, with the required application structure being already deployed inside a container, your ionCube Loader performance can be additionally increased through eliminating from the unrequired files’ processing.

Restricting ionCube Work Area

With default settings, the Loader will examine all the files on a web server for being encoded and process the necessary ones when the appropriate application is launched. In order to accelerate this process and boost decoding performance, it’s a good practice to point Loader to the server location with your encoded files (or directly to the required ones).

Since ionCube Loader represents a PHP extension, its settings can be adjusted within the php.ini configuration file at your application server. To access it, click Config next to the appropriate node and select this file in the File manager panel.
install ioncube loader cloud

At the very end of the opened file, specify the ioncube.loader.encoded_paths directive with a path to the required destination directory or files as its value, e.g.:

ioncube.loader.encoded_paths = “/var/www/webroot/ROOT/index.php

Tips: For more complex customization of processed locations list, use the following formatting options:

  • to specify multiple entries, separate them with a colon “:”, stating plus “+” or minus “” prefix before each path to add/exclude the specified location correspondingly
  • if no prefix is given, a plus sign “+” is assumed  
  • for PHP 5.1 and later, multiple locations can be added within several lines, according to the following syntax:

ioncube.loader.encoded_paths = “/path1″
ioncube.loader.encoded_paths = ${ioncube.loader.encoded_paths}”:/path2″ and so on

Refer to the Loader User Guide for more information on how to define the required ionCube work area.

Do not forget to Save the changes and be sure your data is safe now.

Host your applications with no compromise to security! Try out ionCube Loader for running PHP encoded files in Jelastic Cloud at one of the hosting providers.

Need some details or assistance? Feel free to ask for help within the comments below or get in touch with our technical experts at Stackoverflow.
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

Leave a Reply

Subscribe to get the latest updates