PHP5.6 and APC installation
Asked Answered
A

6

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()
Aldric answered 8/11, 2014 at 15:23 Comment(9)
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 APCuBacteriolysis
What is APCu and is it bundled with PHP 5.6? I don't want to rewrite old code which use APCAldric
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 codeBacteriolysis
Ok.. But how to install apcu?Aldric
launchpad.net/~ondrej/+archive/ubuntu/php5-5.6Bacteriolysis
@MarkBaker APC is MUCH more than opcode cache. apc_fetch() illustrates that. It's still useful in 5.6, but not for opcode cache.Weltschmerz
@Weltschmerz - I'm aware of that, though its limitation is cache per server, so I currently use Redis for data caching in a multi-server environmentBacteriolysis
@MarkBaker Indeed. Smart. Is that a common practice?Weltschmerz
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 regardlessBacteriolysis
B
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.

Baalbeer answered 8/11, 2014 at 15:56 Comment(6)
apt-get install php5-apcu worked for me on Debian wheezy :DAldric
PHP 5.6.x: activate APCu, installing is not enough. read moreTaradiddle
OpCache is not a full blown cache, like APC, it's a simple opcode cache with some optimization steps. And it's not a userland cache - "just" an internal cache, speeding the processing of PHP up.Leclerc
@MarceloRodovalho Maybe I missed something, but nobody here is talking about web server cachingBaalbeer
I use APCu to cache data... OPCache doesn't.Dilly
@Dilly Yes, but the question was about APC, not APCuBaalbeer
R
4

It works for me

yum install php56w-pecl-apcu
Rigger answered 29/10, 2015 at 13:24 Comment(1)
Just an FYI, but APCu is not exactly the same thing as APC. APCu is APC stripped of opcode caching.Baalbeer
T
4

For Amazon Linux, The below command worked for me.

yum install php56-pecl-apcu

Transversal answered 10/8, 2016 at 12:59 Comment(0)
P
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. 🎉)

Pori answered 29/3, 2019 at 17:59 Comment(0)
T
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.

Trawler answered 6/4, 2020 at 7:57 Comment(0)
C
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
Crossbar answered 5/6, 2019 at 9:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.