Install Zend Guard Loader/Zend Optimizer on Debian
Zend Optimizer speed up PHP execution and enable the use of Zend Guard protected files. This guide help you install this PHP extension on Debian.
This how-to is tested on:
- Debian 7.0 Wheezy
This how-to is tested with theses versions of ZendGuardLoader:
- 6.0.0
Prerequisites
This howto needs :
- a working PHP setup, as described by Install PHP-FPM on Debian.
Parameters
Provide the extension archive download URL (available via Zend Guard and Zend Optimizer downloads page) (optional, recommended):
# DOWNLOAD_URL="http://downloads.zend.com/guard/6.0.0/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz"
Provide the ZendGuardLoader version to install:
VERSION="6.0.0"
Provide the ZendGuardLoader build to install (must fit the version):
BUILD="70429"
Installation
Detect the system architecture:
ARCH="$(command dpkg --print-architecture)"
test "${ARCH}" = 'amd64' && ARCH='x86_64'
Detect the PHP version:
PHP_VERSION="$(command php --version 2>'/dev/null' \
| command head -n 1 \
| command cut --characters=5-7)"
Detect PHP extensions installation path:
INSTALL_PATH="$(command find '/usr/lib/php5' -type d -regex '.*/[0-9]*')"
test -z "${INSTALL_PATH}" && INSTALL_PATH='/usr/lib/php5/20100525'
Detect PHP extension configuration path:
MODS_CONF_PATH='/etc/php5/conf.d'
test -d '/etc/php5/mods-available' \
&& MODS_CONF_PATH='/etc/php5/mods-available'
Compute the software download URL, if necessary:
if [ -z "${DOWNLOAD_URL}" ]; then
DOWNLOAD_URL="http://downloads.zend.com/guard/${VERSION}/ZendGuardLoader-${BUILD}-PHP-${PHP_VERSION}-linux-glibc23-${ARCH}.tar.gz"
fi
If PHP is a 5.3 version, force download URL:
test "${PHP_VERSION}" = '5.3' \
&& DOWNLOAD_URL="http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-${ARCH}.tar.gz"
Compute the downloaded filename from URL:
FILENAME="$(command echo "${DOWNLOAD_URL}" | command sed -e 's|^.*/\([^/]*\)|\1|')"
Software installation
Download the software:
command wget "${DOWNLOAD_URL}" \ --output-document="/tmp/${FILENAME}"
Extract the downloaded archive:
command tar --directory '/tmp' -xzf "/tmp/${FILENAME}"
Detect extension file path:
EXTENSION_FILE="$(command find "/tmp/${FILENAME/%.tar.gz/}" -type f -name 'ZendGuardLoader.so')"
Copy the extension binary to the PHP install:
if [ -e "${EXTENSION_FILE}" ]; then
command mkdir -p "${INSTALL_PATH}" command cp "${EXTENSION_FILE}" "${INSTALL_PATH}"
else
echo "Error: ZendGuardLoader.so extension file not found."
fi
Add the extension to the PHP configuration:
if [ -e "${INSTALL_PATH}/ZendGuardLoader.so" ]; then
echo "; configuration for php ZendGuardLoader module
; priority=05
zend_extension=${INSTALL_PATH}/ZendGuardLoader.so" > "${MODS_CONF_PATH}/zendguardloader.ini"
test -n "$(command -v php5enmod)" && command php5enmod 'zendguardloader/05'
fi
Reload the configuration:
test -e '/etc/init.d/php5-fpm' && command service 'php5-fpm' 'restart'
test -e '/etc/init.d/apache2' && command service 'apache2' 'force-reload'
Thanks
- Thanks to Zend for developing PHP (en) and Zend Optimizer (en).