How to install zend optimizer in Centos 7

Introduction

Zend Optimizer is a free application that allows PHP to run files encoded by Zend Guard. Zend Optimizer greatly enhances the performance of PHP applications.
The Zend Optimizer goes over the code generated by the standard Zend run-time compiler and optimizes it for faster execution. The standard Zend run-time compiler used by PHP is indeed very fast, generating code that is usually 2 to 10 times faster. But an application that uses Zend Optimizer can execute scripts another 40% to 100% faster.

Requirement

The following are the software requirement for this installation.

  • Operating System : Centos 7/64bit
  • Web server : Apache 2.4
  • PHP version : 5.4
  • Databae : MariaDB 5.5

You should have a dedicated or VPS centos server with LAMP or LEMP stack.

Install Zend Optimizer

Zend Guard optimization depends on both operating system (64/32 bit) and Php version of the server.

Before starting optimization check the current version of the PHP running in the server.

# arch
x86_64

# php -v
PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Now we can download the appropriate Zend Guard package for the operating system (centos7/64 bit) and PHP version (PHP 5.4) on the server.

Zend Guard Loader (Runtime for PHP 5.4) 64-bit:

# cd /usr/local/src
# wget http://downloads.zend.com/guard/6.0.0/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz

Extract the down loaded package by using tar (tape Archeive)command:

[root@arunima-centos7 src]# tar xzvf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/README.txt
[root@arunima-centos7 src]# cd ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/

The new folder extracted contains ZendGuardLoader.so file and copy it to /etc/php.d/ZendGuard.ini. See example below (use cd command)

# cd php-5.4.x
[root@arunima-centos7 php-5.4.x]# ll
total 1044
-rwxrwxrwx 1 894 nobody 1068334 May  8  2013 ZendGuardLoader.so

# cp ZendGuardLoader.so /usr/lib64/php/modules

Now create ZendGuard.ini file inside /etc/php.d directory:

# vi /etc/php.d/ZendGuard.ini

Server is 64-bit then add below lines to the file /etc/php.d/ZendGuard.ini

; Enable Zend Guard extension
zend_extension=/usr/lib64/php/modules/ZendGuardLoader.so
zend_loader.enable=1

Restart apache service to update changes

# systemctl restart httpd.service

Now check it bye using php -v you can see that php is optimized with zend guard


[root@arunima-centos7 modules]# php -v
PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

Conclusion

Thus we have optimized our php scripts with apache in simple steps.
Note: In case of 32-bit server: zend_extension wil be /usr/lib/php/modules/ZendGuardLoader.so .