Installing php loaders

What is a php loader
PHP loaders are programs that load special php files. They include such pieces of software as
 * Zend_Loader
 * ZendOptimizer
 * PHPShield
 * ionCube

The purpose of all of these pieces of software, with the exception of ZendOptimizer, is to allow the creators of php software some level of copy protection, so all their thieving would-be customers don't just trade copies of their scripts.

It's not too terribly difficult to get a PHP Loader working.

Getting Started
The first thing that needs to be done before you can use a php loader, is you must install a custom php.ini file. There are extensive instructions already, which can be found Custom_PHP.ini

Just follow these instruction through exactly. If you are using php5, then you need to use the name php5.cgi every time that wiki article says php.cgi.

Check that PHP.ini is working correctly
You should really check and make sure that your php.ini file is working correctly before proceeding. Make a script called phpinfo.php with the following contents, and upload it to your site.


 * Source of phpinfo.php

Simple enough. When you view this file through a browser you'll see a whole page of information on php. Scroll down to Loaded Configuration File - it should have the path of your home directory, not /etc/php.

ZendOptimizer, ZendLoader and ZendGuard
These are installed on Dreamhost servers by default. You should not have to do anything additional to install them.

However, these are only installed for PHP 5.2 (which is enabled by default), so if you switch to PHP 5.3 you will need to install a compatible version of ZendGuard.

You can do this by running the following commands:

wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so YOURDOMAIN.com/cgi-bin/

You will also need to edit the PHP.ini settings by creating a phprc file with the following line:

zend_extension = /home/YOURUSERNAME/YOURDOMAIN.com/cgi-bin/ZendGuardLoader.so

ionCube
First, use the phpinfo.php script to figure out what version of php you are using. It'll either be php 5.2 or php 4.4.

Go to your custom php.ini file. At the very bottom, add the line

zend_extension="/home/YOUR_USER/YOUR_SITE/ioncube/ioncube_loader_lin_5.2.so"
 *  PHP 5.2 

zend_extension="/home/YOUR_USER/YOUR_SITE/ioncube/ioncube_loader_lin_4.4.so"
 *  PHP 4.4 

Once you have done that, go slightly up, and find the two other zend_extension statements. These are for ZendOptimizer. Comment them out so that it looks like


 *  Zend stuff begone 
 * 1) zend_extension="/usr/local/dh/apache/template/phpext/ZendExtensionManager.so"
 * 2) zend_extension="/usr/local/dh/apache/template/phpext/zend_optimizer5/ZendOptimizer.so"

If you get an Internal service error than you most likely did not comment out the Zend stuff. Note that contrary to ioncube's instructions, the web server does not need to be restarted.

'''A great alternative is the ionCube script provided on. It does everything described above in this section. If you use the phpini script from the same forum, first run that script and afterwards the ionCube script.'''

PHPShield
Installing PHPShield is similar to installing ionCube. Their instructions can be found here

Find a line in your php.ini labeled enable_dl. It should look like

enable_dl=On
 * Enable_dl

It should be on already, but you need to check. Then find a line that says extension_dir

extension_dir="/home/YOUR_USER/YOUR_SITE/"
 * Extension_dir

It might work at this point, but for the sake of completeness add the following to the end of php.ini

extension=phpshield/phpshield.5.2.lin
 * PHP 5

extension=phpshield/phpshield.4.4ts.lin
 * PHP 4

The phpshield directory must be a subdirectory of the extension_dir!

The phpSHIELD loader can be downloaded from. Depending on what server you are on, you will need either the Linux or the Linux 64-bit version. You can find out which one by entering the following command in a shell: uname -m If this prints "i386", you need the Linux version; if it prints "x86_64", you will need the 64-bit Linux version.

At this point, your phpSHIELD/ionCube protected scripts should work. Woot. A way that you can check if it's loaded is to load phpinfo.php in your browser again. At the very bottom of that page you'll see something like:

Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies with the ionCube PHP Loader v3.1.32, Copyright (c) 2002-2007, by ionCube Ltd.

This will tell you if the extension has been loaded correctly without using any ioncube encoded scripts. phpSHIELD should leave a similar message.