Yes, PHP APCu Extension (Version 5.1.22 and newer) works with PHP 8.2. Installing and configuring APC (and APCu) on the Apache server was never just running one command. However, PHP 8 changed many things and installing and configuring APCu become more complex.
Our old article on Installing APC on PHP 7.2 shows how we used to install PHP APCu in the previous versions plus gives the idea of configuring and monitoring/visualization.
PHP 8.2 is a version which was released near the end of 2022. This is a major release of PHP. This version contains many new features, deprecated dynamic properties and performance improvements. We recommend you test your app and code with PHP 8.2 before upgrading to a production server. Especially for many WordPress plugins, there are breaking changes.
---
This is the APCu we are talking about:
1 | https://github.com/krakjoe/apcu/releases/tag/v5.1.22 |
Steps to Install the PHP APCu Extension
We will use the latest Ubuntu and Ondřej Surý’s PHP PPA to demonstrate. Ondřej invests a lot of time in Apache, PHP and many other server packages. Consider sponsoring him on GitHub, sponsorships start from $1/month:
1 | https://github.com/sponsors/oerdnj |
Install a few dependency packages before adding the repository:
1 2 | sudo apt update sudo apt install -y lsb-release gnupg2 ca-certificates apt-transport-https software-properties-common |
Add Surý PPA to your system:
1 2 3 | sudo add-apt-repository ppa:ondrej/php # Press [ ENTER ] sudo apt update |
Install PHP 8.2 :
1 2 3 4 5 6 7 | sudo apt install php8.2 # check php -v && php --version # install some modules sudo apt install php8.2-{bcmath,xml,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,soap,cgi} # check the installed modules php -m |
In Apache, we can use mod_php
to process PHP code directly. You need to install the Apache web server package, PHP, and Apache PHP extension:
1 2 3 | sudo apt install apache2 libapache2-mod-php8.2 sudo a2enmod php8.2 sudo systemctl restart apache2 |
Install APCu:
1 | pecl install apcu |
You’ll get output like this:
1 2 3 4 5 6 7 8 9 | pecl install apcu downloading apcu-5.1.12.tgz ... Starting to download apcu-5.1.12.tgz (105,890 bytes) ........................done: 105,890 bytes 39 source files, building running: phpize Configuring for: ... ... |
Update the php.ini
file located here :
1 | /usr/local/etc/php/8.2 |
Open the PHP.ini file which is under Apache’s path, like :
1 | nano /etc/php/8.2/apache2/php.ini |
and edit like we did in the previous tutorial.
Add apcu extension in:
1 | nano /usr/local/etc/php/8.2/conf.d/ext-apcu.ini |
Add this:
1 2 | [apcu] extension= <path> see below |
The
will be like /usr/local/../php/8.2.4/pecl/20220829/apcu.so
. To find it, run:
1 2 3 | apt install mlocate sudo updatedb locate apcu.so |
Restart Apache:
1 | sudo systemctl restart apache2 |
You can check APC settings in the system with this command :
1 | php -r 'phpinfo();' | grep -i 'apc' |
If everything works fine then try the other settings from our old article.