7

How to install APC under PHP 5.6?

APC is installed

apt-get install php-pear php5-dev make libpcre3-dev
pecl install apc

# locate apc.so
/usr/lib/php5/20100525/apc.so

APC is added to php.ini

extension=apc.so

But APC is not mentioned in output from phpinfo()

Fatal error: Call to undefined function apc_fetch()
clarkk
  • 27,151
  • 72
  • 200
  • 340
  • 3
    Don't install APC with PHP 5.6, because you have OpCache as an opcode cache instead. If you need APC for user data, then use APCu – Mark Baker Nov 08 '14 at 15:25
  • What is APCu and is it bundled with PHP 5.6? I don't want to rewrite old code which use APC – clarkk Nov 08 '14 at 15:26
  • No, it isn't bundled with PHP 5.6.... its a userdata only version of APC (none of the opcode caching because that's handled now by OpCache), but 100% compatible with the old APC for caching data from within your code – Mark Baker Nov 08 '14 at 15:29
  • 1
    Ok.. But how to install apcu? – clarkk Nov 08 '14 at 15:30
  • https://launchpad.net/~ondrej/+archive/ubuntu/php5-5.6 – Mark Baker Nov 08 '14 at 15:32
  • @MarkBaker APC is MUCH more than opcode cache. `apc_fetch()` illustrates that. It's still useful in 5.6, but not for opcode cache. – Rudie Nov 08 '14 at 15:59
  • @Rudie - I'm aware of that, though its limitation is cache per server, so I currently use Redis for data caching in a multi-server environment – Mark Baker Nov 08 '14 at 16:14
  • @MarkBaker Indeed. Smart. Is that a common practice? – Rudie Nov 08 '14 at 18:44
  • Not sure it's common practise, but it's pretty useful, and redis might not be quite as fast as APCu but it's pretty close.... I even use it for sessions, so it doesn't matter which webhead a user hits, their session is maintained regardless – Mark Baker Nov 08 '14 at 18:51

6 Answers6

10

APC is (more or less) a deprecated package (the last release, 3.1.14, was unstable and had to be rolled back). It has been replaced by the core package opcache.

I'm not sure about Debian flavors (all my searches return the PECL library while opcache is native to 5.6) but in CentOS you have to install the php-opcache package, which contains the opcahce.so file.

Machavity
  • 30,841
  • 27
  • 92
  • 100
4

It works for me

yum install php56w-pecl-apcu
Rjazhenka
  • 1,278
  • 1
  • 10
  • 5
  • Just an FYI, but APCu is not exactly the same thing as APC. [APCu is APC stripped of opcode caching.](https://github.com/krakjoe/apcu) – Machavity Jul 14 '16 at 13:14
4

For Amazon Linux, The below command worked for me.

yum install php56-pecl-apcu

Arul Deepan
  • 159
  • 2
  • 6
3

As mentioned by others on this question, on PHP 5.6, you probably don't want the full APC package. Instead, you almost certainly just want the user-data caching portion, APCu.

If you're using PECL, you need to specify the correct version of APCu to use which appears to be 4.0.11:

pecl install apcu-4.0.11

(Worked for me on CentOS 6, EasyApache 3, Apache 2.2, PHP 5.6.39. )

rinogo
  • 8,491
  • 12
  • 61
  • 102
1

On Ubuntu 18.04 simply running

sudo apt install php-apcu

and enabling it on /etc/php/5.6/apache2/php.ini by adding this lines at the end of the file:

extension=apcu.so
apc.enabled=1

(and restarting apache2 if necessary)

sudo service apache2 restart

Worked for me.

Raül Ojeda
  • 69
  • 1
  • 6
0

On Ubuntu 18.04 this worked for me:

  1. Download rpm from here

  2. install alien to able to install rpm

    sudo apt-get install alien
  1. install apcu
    sudo alien -i ~/Downloads/php56-php-pecl-apcu-4.0.11-1.el7.remi.x86_64.rpm
  1. open apcu.ini
    sudo nano /etc/php/5.6/cli/conf.d/20-apcu.ini
  1. add these lines to enable apcu
    extension=apcu.so
    apc.enabled=1
    apc.enable_cli=1
Pavel Alazankin
  • 1,325
  • 1
  • 12
  • 22