In today’s modern world, the copyrighted content is something very important. When you have spent a lot ofwork creating a web application, but if there is no protection available, someone can easily take advantage of your work and copy your code. This is an issue ! There are many tools out there to protect the php code such as Zend Guard, Source Guardian, phpshield, ioncube and many more which may in form apache modules or as compiler for the source.
Behind every encoding decoding algorithm process there must be some decreasing in performance as the price we have to pay, but no worry, there is something we could do to minimize this effect by optimizing the php itself using php optimizer such as phpaccelerator or Zend Optimizer.
This time I would like to share how to install ioncube php encoder and Zend Optimizer php accelerator on Debian Lenny server. The installation and configuration is pretty easy, all we need is ioncube and Zendoptimizer source lib. The source can be downloaded from here for ioncube source and here is the zendoptimizer source. Please pay attention on the OS architecture before downloading. Currently I’m using 64bit Lenny, so I choose x86-64 ioncube_loaders_lin_x86-64.tar.bz2 and ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
Ioncube Loader :
1. Place the downloaded file into tmp, and extract them :
{code}cd /tmp
tar zxvf ioncube_loaders_lin_x86-64.tar.bz2{/code}
2. Create the library folder :
{code}mkdir /usr/local/ioncube{/code}
3. Move that zendoptimizer library into them :
{code}mv ioncube_loaders_lin_x86-64/ioncube/ioncube_loader_lin_5.2.so /usr/local/ioncube{/code}
(Your ioncube_loader library name may be different since it includes version numbers and platform. I’m using ioncube_loader_lin_5.2.so because I have PHP 5.2 installed.)
4. Add reference to your php.ini file (nano /etc/php5/apache2/php.ini)
{code}zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.2.so{/code}
(You may put this reference into subdomain specific fcgi php.ini setting location when you’re using hosting control panel such as ispcp or vhcs)
5. Restart the apache web server
{code}/etc/init.d/apache2 restart{/code}
Zend Optimizer :
1. Place the downloaded file into tmp, and extract them :
{code}cd /tmp
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz{/code}
2. Create the library folder :
{code}mkdir /usr/local/zendoptimizer{/code}
3. Move that zendoptimizer library into them :
{code}mv ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/zendoptimizer{/code}
(Your ZendOptimizer directory name may be different since it includes version numbers and platform. I’m using the 5_2_x_comp directory because I have PHP 5.2 installed.)
4. Add reference to your php.ini file (nano /etc/php5/apache2/php.ini)
{code}zend_extension = /usr/local/zendoptimizer/ZendOptimizer.so
zend_optimizer.optimization_level = 15{/code}
(You may put this reference into subdomain specific fcgi php.ini setting location when you’re using hosting control panel such as ispcp or vhcs)
5. Restart the apache web server
{code}/etc/init.d/apache2 restart{/code}
Testing it :
Time to check the fruit of the labor, in the ioncube_loaders_lin_x86-64.tar.bz2 there are two files included by the developer ioncube-encoded-file.php and ioncube-loader-helper.php to check the ioncube library functionality. Move the two php file into the webroot html folder and try to acces them with your browser :
http://<yourdomain.tld>/ioncube-encoded-file.php
if everything fine, there should be a message shown :
This file has been successfully decoded. ionCube Loaders are correctly installed.
and if not, then you will read this message :
This encoded file cannot be run. Please run the file ioncube-loader-helper.php for more information.
check again the specified library path or investigate the php version.