How to Install APCu for PHP 5.5 and 5.6 CentOS , Ubuntu & Debian

APCu is Extension PHP used after APC was deprecated.


The Alternative PHP Cache (APC) is a free and open opcode cache for PHP.

Since March 2013, a beta version of APCu (APC User Cache) is available,in which all opcode caching abilities have been removed Because APC had compatibility issues. First stable version 4.0.8 was released on 2015-11-20.It is Compatible  with PHP 5.5 and 5.6 but some older version works with PHP 5.4.Latest Version is 4.0.11.

This version of APC has opcode cache part removed so, Zend Opcache now ships by default in 5.5 and later versions . you can install this cache by the following command :

For Centos

sudo yum install php-opcache.

Installation of  on CentOS:

This installation will work on debian and ubuntu too . just change yum to apt-get

To install this extension on PHP, SSH in to your server & use sudo and run these commands:

 sudo yum install gcc make autoconf pkg config

Install PECL if its not installed :

 sudo yum install php-pear

Then Install the latest version

 sudo pecl install apcu-4.0.11

When prompted for the following questions, press Enter.

 Enable full APC compatibility [yes] :
 Enable internal debugging in APC [no] :

Now its  installed But not Activated.To activate this extension we need to create a config file.
first create a file .ini using nano editor

nano /etc/php.d/apcu.ini

nano /etc/php5/fpm/apcu.ini   //for Ubuntu or Debian

Now paste these lines in file:

 apc.shm_segments = 1
 apc.shm_size = 32M
 apc.entries_hint = 512
 apc.ttl = 7200
 apc.gc_ttl = 7200
 apc.mmap_file_mask = "/tmp/apc.XXXXXX"
 ;apc.slam_defense = 1
 apc.enable_cli = 0
 ;apc.use_request_time = 1
 ;apc.serializer = "default"
 ;apc.rfc1867 = 0
 ;apc.rfc1867_prefix = "upload_"
 ;apc.rfc1867_name = "APC_UPLOAD_PROGRESS"
 ;apc.rfc1867_freq = 0
 ;apc.rfc1867_ttl = 3600
 ;apc.coredump_unmap = 0

Press ctrl+x to exit ,then y to save the file and hit enter to confirm.

now to load the configuration we have to restart apache

sudo service httpd restart 
service apache2 restart //for debian and ubuntu

Confirm installtion using the following command:

php -r 'phpinfo();' | grep 'apcu'

result should be this is centos


Thats it Done!. Share this Post with others & Subscribe to SpanBlog for more.

UPDATE For Ubuntu/Debian: If this doesn’t work after php-pear installation is done.

You can Install via apt-get install php-apcu & restart phpfpm via service php5-fpm restart .  

Make sure you have repositories for your Operating System in /etc/apt/sources.list file for this to work.


Leave a Reply

Your email address will not be published. Required fields are marked *