Zend Opcache extension installation
If you want to speedup your PHP application maybe you are looking for a PHP accelerator such APC cache.
Since PHP 5.5 there is another option for caching Opcodes (details): Zend OpCache extension
If you are using PHP 5.5.0 and later Zend Opcache extension may be compiled with PHP, you have only to configure it.
If you are using a older version of PHP you can compile the extension following few simple steps:
- Download latest version here https://github.com/zendtech/ZendOptimizerPlus
- Configure the compilation with your php config
- Build the package
- Install will copy the binary file to your extension directory (or you can copy by your own)
After the compilation was successfully finished you can declare your new extension into php.ini file
Zend Opcache configuration
The full parameters list are listed on Zend Opcache documentation
I will just mention few of the parameters you have to consider in your configuration
- revalidate_freq – configure how often the file time stamp is checked to detect file changes. 0 – means check every time. You have to configure revalidate_freq 0 on your development machine. On production I am using a large number such as 3600
- validate_timestamps – When disabled, you must reset the OPcache manually or restart the
webserver for changes to the filesystem to take effect. I advice you to use it on production server and create a hook to clear Opcache after release
- max_accelerated_files – them maximum number of scripts stored in opcached memory. you can count your code-base using find . -type f -print | grep php | wc -l
- memory_consumption – the amount of memory to store pre-compiled PHP files
You can read here a performance benchmark report here on the same subject.