APCu is the substitute for the old APC extension. In APC extension it supports both opcode caching and data caching whereas APCu extension supports only data caching. Opcode caching is transparent at a source code level where as data caching is not.The main thing to note is that we need to allocate memory for APCu to use.
Configuration On Ubuntu System
First, we need to install the php7.1 module APCu. We do with Usual ubuntu command Like this.
apt-get install php7.1-apcu
After the successful installation of the module, we need to modify the configuration file which is in most case at location
“/etc/php/7.1/mods-available/apcu.ini”
Then we need to Make changes in this file to enabling and tweaking the size of APCu. Here are the changes we made in the config file.
extension=apcu.so
apc.enabled=1
apc.shm_size=64M
apc.ttl=7200
apc.gc_ttl=3600
apc.enable_cli=0
apc.shm_size
This will allocate 64MB from the RAM to APCu for its caching purposes.
apc.enabled
apc.enable enables it for PHP-fpm and apc.enabled can be set to 0 to disable APCu.
apc.enable_cli
Activates it for command line-PHP like cronjobs.
apc.ttl
The number of seconds a cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry.
apc.gc_ttl
The number of seconds that a cache entry may remain on the garbage-collection list.Set to zero to disable this feature.
If you need the different type of configuration like apc.user_ttl, apc.filters etc.. you can also add with above settings.
After the completion of the configuration, save the file and make the symlink.
“sudo ln -s /etc/php/7.0/mods-available/apcu.ini /etc/php/7.0/fpm/conf.d/30-apcu.ini”
Restart php7.1-fpm service
To check the APCu size use this command
“php -i | grep apc.shm_size”
It will results like this
“apc.shm_size => 64M => 64M”