21

I have installed APCu extension in PHP7

But I get this error

Call to undefined function apc_fetch()

enter image description here

5 Answers 5

27

Starting with PHP 7.0, APCu removed the option for full backwards compatibility with APC that existed with APCu in PHP 5.5 and 5.6.

You will need to add the APCu Backwards Compatiblity Module on top of apcu to make it work. (https://pecl.php.net/package/apcu_bc)

pecl install apcu_bc
Sign up to request clarification or add additional context in comments.

Comments

19

You need to install apcu and apcu backward compatibility for PHP7

On Ubuntu 14.xx you first need to install php7.0 by using the repo:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0

Then

sudo apt-get install php7.0-apcu
sudo apt-get install php7.0-apcu-bc

Then restart apache

For ubuntu 16.xx. You can already install apcu

sudo apt-get install php-apcu

Then add the repo:

sudo add-apt-repository "deb http://ftp.de.debian.org/debian sid main"
sudo apt-get update

then

sudo apt-get install php-apcu-bc

3 Comments

These packages seem to not exists in ubuntu 16 repos
You are right I will update the answer with the info for the package :)
I know I'm late to the party but it's worth noting that you'll also need to restart apache after the Ubuntu 16 instructions as well.
6

Such an installation doesnt work for me - ubuntu doesnt have apcu-bc package.

apt-get install php7.0-apcu-bc

My installation

sudo apt-get install php-dev
sudo pecl install apcu_bc-beta

After that I changed /etc/php/7.0/mods-available/apcu-ini to

extension=apcu.so
extension=apc.so

Note, that apc.so must be AFTER apcu

2 Comments

Is the -beta part required for the install from pecl?
@Sonny sorry, I dont know
2

APC and APCu are different modules.

You have APCu installed, however, you are using APC functions.

Try apcu_fetch or install apc, if that is possible for PHP7.

Comments

1

In Centos using IUS repo, install apcu and apcu-bc packages for php7:

sudo yum install php71u-pecl-apcu php71u-pecl-apcu-bc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.