OpCache install & configuration
Install OpCache on FreeBSD with (note 56
resembles the current PHP version 5.6):
cd /usr/ports/www/php56-opcache && sudo make config-recursive install distclean
Open up php.ini
to configure OpCache settings:
sudo ee /usr/local/etc/php.ini
Find and uncomment the following directives (by removing the ;
at the front of the directive's line), then set their values to the required value:
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.use_cwd=1
opcache.revalidate_freq=60
opcache.fast_shutdown=1
The following can also be set, but in applications that use code comments as executable code (i.e. symfony's annotation) this will cause problems as it will strip comment out of the pre-compiled byte code:
opcache.save_comments=0
opcache.load_comments=0
opcache.max_accelerated_files
should be higher than the amount of PHP files that are going to be cached. Fine tune this by counting the number of .php
files in your project directory with (note the path used here is the default Apache DocumentRoot path, change as needed):
find /usr/local/www/apache24/data -iname *.php|wc -l
Check the OpCache running configuration in the command line with:
php -r 'var_dump(opcache_get_configuration());'
Check the status of OpCache with:
php -r 'var_dump(opcache_get_status(false));'
Restart Apache:
sudo apachectl graceful
###References