Install APCU extension for Azure App Service Linux PHP 7.4

2 minute read | By Christopher Maldonado

Installing PHP extension APC for Azure App Services on Linux PHP 7.4


There are many different caching solutions for various types of applications out there. Alternative PHP Cache is an opcode caching plugin for PHP. With APC, your PHP script executions will run more efficiently.


Navigate to your App Service via the Azure Portal. Under the Development Tools section, select SSH then Go -->.

Building the APCu extension

Using PECL to install the extension at times can fail, so here we will be doing a manual build and install.

Create a new folder and navigate to the newly created directory.

mkdir -p /tmp/pear/temp
cd /tmp/pear/temp

In the next steps we will download the bundled source using pecl to configure and build the .so extension file.

pecl bundle apcu
cd apcu

After a successful configure and make, a new directory called modules will have been created with an and file. Move the .so file into your home directory. For example, /home/site/ext.

mkdir -p /home/site/ext
cp /tmp/pear/temp/apcu/modules/ /home/site/ext

With the new extension moved to a location where it will persist after a restart, a .ini file is needed so that PHP can load this extension when it starts up. Create a new directory for your .ini file.

mkdir -p /home/site/ini
echo "extension=/home/site/ext/" > /home/site/ini/apcu.ini

To ensure that PHP picks up this extension and loads it, an App Setting can be configured to point PHP to look inside this directory for any additional .ini files.

Navigate to your App Service via the Azure Portal. Under the Configuration section, select New application setting.

Value: /usr/local/etc/php/conf.d:/home/site/ini

Save these changes and restart your App Service.

Verify if APCU extension has been loaded

There are two ways you can verify if the extension was loaded successfully. First, would be to create a php file with the following code inside:

<?php phpinfo(); ?>

This will output all your PHP configuration settings and more. Search for APCu and a section dedicated to this extension should be displayed.

The second way to verify is using the SSH option under Development Tools.

Here you will run the following command and the output will be the apcu specific settings.

php -i | grep apc


Enabling this extension is optional for most PHP applications. However, this is beneficial for PHP Content Management Systems. The extension helps to provide additional performance specific to PHP scripts.