Installing Zend Optimizer Plus (OPCACHE) on CentOS

Joe Huss

Administrator
Staff member
Here is a 1-line script you can copy/paste to download/install latest version of Zend Optimizer Plus (zend opcache). Zend Optimizer Plus has been recognized as being one of the most stable and powerful of the PHP optimizers, and is now included by default in php 5.6.

It downloads the latest version of Zend Opcache from its main git repo and builds /tests / installs / tests the install / automatically removes on errors. It was written with CentOS in mind but should work on any distribution (git and php-devel might need to be installed manually). if It will automatically install git and php-devel if they are not installed. The tests the return value of each command before going to the next so that if any part of the script fails it stops the install right away.

Code:
if [ "$(phpize |grep "find PHP head")" != "" ]; then yum -y install php-devel; fi && if which git 2>/dev/null; then echo yum installed; else yum -y install git; fi && git clone https://github.com/zendtech/ZendOptimizerPlus.git && cd ZendOptimizerPlus/ && phpize && ./configure --with-php-config=$(which php-config) && make && echo n | make test | tee test.results && if [ "$(grep -e "Tests [failed|warned]" test.results  | awk '{ print $4 }'|grep -v "^0$")" == "" ]; then make install; fi && echo -e "; Enable Zend Opcache\nzend_extension=/usr/lib/php/modules/opcache.so\nopcache.memory_consumption=128\nopcache.interned_strings_buffer=8\nopcache.max_accelerated_files=4000\nopcache.revalidate_freq=60\nopcache.fast_shutdown=1\nopcache.enable_cli=1\n" > /etc/php.d/10opcache.ini && if [ "$(php -m |grep "Zend OPcache")" != "" ]; then echo "Zend Optimizer Plus (OPCACHE) Installed Successfully"; else sed s#"^zend_ext"#";zend_ext"#g -i /etc/php.d/10opcache.ini; echo -e "Zend Optimizer Plus (OPCACHE) Installation FAILED\n\nopcache.so PHP Module Disabled due to problems\n"; fi;
After it is installed you will need to restart your webserver (ie apache with /etc/init.d/httpd restart)

To remove it you can copy/paste this:
Code:
echo -n "Removing opcache...";rm -rf /root/ZendOptimizerPlus /etc/php.d/10opcache.ini /usr/lib/php/modules/opcache.so; echo "done";

 

Serge

New Member
Thank you for the script !
However on CentOS 6.4 I met the following message
***
/usr/bin/git
yum installed
Initialized empty Git repository in /root/ZendOptimizerPlus/.git/
remote: Counting objects: 1104, done.
remote: Compressing objects: 100% (509/509), done.
remote: Total 1104 (delta 719), reused 953 (delta 588)
Receiving objects: 100% (1104/1104), 277.85 KiB, done.
Resolving deltas: 100% (719/719), done.
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module
***

I tried to install it on server under Plesk Panel 11.5 - so that I'm not sure what does mean
"Make sure that you '/usr/bin/phpize' in the top level source directory of the module"

I just can confirm that real location of 'phpize' is /usr/bin/phpize
But why it cannot find config.m4 under /root/ZendOptimizerPlus/config.m4 ?

Could you advise what to do with that ?
Thank you in advance !
Best regards,
Serge
 

Serge

New Member
Yes, I have php-devel installed
"Package php-devel-5.4.21-27.el6.art.x86_64 already installed and latest version"
 

Quags

Administrator
Staff member
Hard to say on the original error provided, but since its not related to php-devel you may be missing gcc
 
Top