Installing PHP 7.0 APCu Extension

By Digamber Rawat Last updated on
In order to include object caching functionality in PHP 7.0, The APCu extension is used.

Earlier APC extension was used, but it has been replaced by APCu nowadays. The previous version used to be known by the APC in PHP 5.5, it used to provide opcode and object caching functionality. However, as the time pass by developer created APCu which is more flexible and robust.

How to Install APCu on PHP 7.0, 7.1, 7.2 ?

In order to install APCu extension in PHP 7.0, 7.1, 7.2 +, you must log inside your server as a root user using SSH access. Hit below commands in your terminal.

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
# Replace X with your php version number
sudo pecl7.X-sp install apcu

It will ask the given below question, hit enter.

# Hit Enter in response to this question
Enable internal debugging in APCu [no] :

As soon as you entered the above command, it will start processing once it is finished with the process. Then create a file to keep the configuration for the extension, finally run the below command as a root user to restart the PHP.

# Replace php7.X-sp => X with your PHP version
sudo bash -c "echo extension=apcu.so > /etc/php7.X-sp/conf.d/apcu.ini"
# Replace php7.X-sp => X with your PHP version
sudo service php7.X-fpm-sp restart

APCu creates some problems if you are using PHP 7+ versions. To provide full backward compatibility with APCu with PHP 7+, we should install APCu Backwards Compatibility extension.

How to Verify PHP APCu Installation?

Use the below command to make sure whether the APCu PHP extension is installed precisely.

phpX.Y-sp -i | grep apcu

Following will be the output of above cmd:

# Replace php7.X-sp => X with your PHP version
Additional .ini files parsed => /etc/phpX.Y-sp/conf.d/apcu.ini,

apcu

How to Uninstall the PHP APCu Extension?

Type the below command in terminal, to uninstall the PHP APCu extension.

# Replace php7.X-sp => X with your PHP version

sudo rm /etc/phpX.Y-sp/conf.d/apcu.ini
sudo peclX.Y-sp uninstall apcu

Finally, don’t forget to restart the PHP-FPM:

sudo service phpX.Y-fpm-sp restart

Digamber Rawat
Digamber Rawat

Full stack developer with a passion for UI/UX design. I create beautiful and useful digital products to solve people’s problem and make their life easy.