ZendOpcache on CloudLinux with LSAPI

xlightwaverx

Member
Sep 27, 2014
14
3
3
cPanel Access Level
Root Administrator
Hi. I am having some issues getting ZendOpcache to run on my CloudLinux system using Native PHP5.4

I can successfully get ZendOpcache to run on PHP Selector by checking opcache from PHP settings, but that leads to another issue.

My two issues are these:

1) How do I enable ZendOpcache to run on Native PHP 5.4 (So all users can benefit from it) while running LSAPI?

I have used PECL to install ZendOpcache for PHP 5.4 and saw some issues in the output where the script is looking for zendopcache.so but it only puts opcache.so under extensions in php.ini. Either way when mapping the correct file and setting the .so file to 755 like the others in that directory, ZendOpcache fails to register in PHPInfo.

2) How do I make changes to PHP Selector 5.4 ini files that have ZendOpcache enabled so I can configure the ZendOpcache settings so I can configure stuff like (how long it caches for instead of a few seconds, how big the cache is, etc)?

I have tried editing cagefsctl -e USERNAME to adjust the alt-php.ini for that account, and that doesn't work. I have also tried editing /opt/alt/php54/etc/php.d.all/opcache.ini and adding the requested changes to that file, executing cagefsctl --rebuild-alt-php-ini, and still I ending up with nothing.

Please advise on how to get either method to run correctly, as I would prefer a global PHP 5.4 with ZendOpcache and LSAPI.
 

xlightwaverx

Member
Sep 27, 2014
14
3
3
cPanel Access Level
Root Administrator
Here is example of file: /opt/alt/php54/etc/php.d.all/opcache.ini

Code:
; Enable opcache extension module
zend_extension=/opt/alt/php54/usr/lib64/php/modules/opcache.so
opcache.revalidate_freq=0
opcache.validate_timestamps=0 (comment this out in your dev environment)
opcache.max_accelerated_files=7963
opcache.memory_consumption=192
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1
Here is ZendOpcache section of pulled from PHPInfo:

Code:
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli Off Off
opcache.enable_file_override Off Off
opcache.error_log no value no value
opcache.fast_shutdown 0 0
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.inherited_hack On On
opcache.interned_strings_buffer 4 4
opcache.load_comments 1 1
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 2000 2000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 64 64
opcache.optimization_level 0xFFFFFFFF 0xFFFFFFFF
opcache.preferred_memory_model no value no value
opcache.protect_memory 0 0
opcache.restrict_api no value no value
opcache.revalidate_freq 0 0
opcache.revalidate_path Off Off
opcache.save_comments 1 1
opcache.use_cwd On On
opcache.validate_timestamps Off Off
Even after rebuilding the CageFS ini files and even trying to restart apache, this yeilds nothing.
 

someB0dy

Member
May 24, 2010
22
2
53
cPanel Access Level
Root Administrator
Hi,

You do not need to compile Zend Opcate manually, it is already built in CloudLinux PHP-Selector, which is required by LSAPI. The right path to enable it globally will be:
- determine default PHP version for native php (php -v as root)
- open /usr/local/lib/php.ini and add opcache.so same version as native php is, e.g. for 5.4 :

Code:
; Enable opcache extension module
zend_extension=/opt/alt/php54/usr/lib64/php/modules/opcache.so
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.max_accelerated_files=7963
opcache.memory_consumption=192
opcache.interned_strings_buffe
- run 'cagefsctl --force-update' after each editing main php.ini file

By this you will get opcache enabled for 'native' lsphp .


To edit global config parameters for opcache you edit right file - /opt/alt/php5*/etc/php.d.all/opcache.ini , for every PHP version. However looks like it will not work for you as you have a syntax error there - remove the text next to opcache.validate_timestamps=0 , it should be clean as mine above.
 
  • Like
Reactions: xlightwaverx

xlightwaverx

Member
Sep 27, 2014
14
3
3
cPanel Access Level
Root Administrator
Hi,

You do not need to compile Zend Opcate manually, it is already built in CloudLinux PHP-Selector, which is required by LSAPI. The right path to enable it globally will be:
- determine default PHP version for native php (php -v as root)
- open /usr/local/lib/php.ini and add opcache.so same version as native php is, e.g. for 5.4 :

Code:
; Enable opcache extension module
zend_extension=/opt/alt/php54/usr/lib64/php/modules/opcache.so
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.max_accelerated_files=7963
opcache.memory_consumption=192
opcache.interned_strings_buffe
- run 'cagefsctl --force-update' after each editing main php.ini file

By this you will get opcache enabled for 'native' lsphp .


To edit global config parameters for opcache you edit right file - /opt/alt/php5*/etc/php.d.all/opcache.ini , for every PHP version. However looks like it will not work for you as you have a syntax error there - remove the text next to opcache.validate_timestamps=0 , it should be clean as mine above.
Thank you. This worked. I have to assume the PECL version from EasyApache or at least the location of where EA put the .so file was not reachable by the users CageFS paths. The IonCube one that is already there is a different path than the one PECL placed for me.

As for the incorrect syntax, you maybe right. I must have thought it was commented out to start with. I have not tried adjusting the PHP Selector versions that yet, though I do recall seeing the php log errors when testing but all other variables should have worked except that line where the invalid syntax was, or if not, at least up to the next commented line, which probably was after that section of the .ini

Anyway, thanks again!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,883
2,256
463
Hello :)

I am happy to see the issue is now addressed. Thank you for updating us with the outcome.

Thank you.