How to Install PHP APCu on ubuntu 16.04

How to Install PHP APCu on ubuntu 16.04

 

What is APCu

APCu (APC User Cache) is an in-memory key value store for PHP which provide better performance. It is a drop in replacement for APC.

How to download APCu

Latest stable release of APCu (in tgz format) can be downloaded from php.net website : https://pecl.php.net/get/APCu

Click on the below URL to check APC user cache documentation on php.net website :

http://php.net/manual/en/book.apcu.php


 

Steps to install APCu PHP extension

Do the below steps to install APCu on Ubuntu Server

1. Log into your Ubuntu server as ‘root’ user or login as any user with sudo privileges

2. Run the below command to check whether php APCu is already installed and enabled on the server

 

root@server:~# php -m | grep -i apcu

 

If APCu isn’t installed, the above command won’t return any output.

3. Run the command ‘pecl install apcu’ to install APCu on the server.

 



 

# pecl install apcu

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading apcu-5.1.16.tgz ...
Starting to download apcu-5.1.16.tgz (94,032 bytes)
.....................done: 94,032 bytes
38 source files, building
running: phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
Enable internal debugging in APCu [no] :
building in /tmp/pear/temp/pear-build-rootxU5reS/apcu-5.1.16
running: /tmp/pear/temp/apcu/configure --with-php-config=/usr/bin/php-config --enable-apcu-debug=no

Build process completed successfully
Installing '/usr/include/php/20151012/ext/apcu/apc_cache.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_lock_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_serializer.h'
Installing '/usr/include/php/20151012/ext/apcu/php_apc.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_lock.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_mutex.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_iterator.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_stack.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_arginfo.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_globals.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_cache_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_sma_api.h'
Installing '/usr/include/php/20151012/ext/apcu/apc_sma.h'
Installing '/usr/lib/php/20151012/apcu.so'
install ok: channel://pecl.php.net/apcu-5.1.16
You should add "extension=apcu.so" to php.ini

 
4. Append the line “extension=apcu.so” to the end of php configuration file

run the command ‘php --ini’ to check the Loaded PHP Configuration File

echo “extension=apcu.so” >> /etc/php/7.0/cli/php.ini

5. Now run the command “php -m | grep -i apc” to check whether it is enabled.

 

root@server:~# php -m | grep -i apc
apcu