43

I am running a web server with the following packages; php-apc 3.1.7-1 php5-fpm 5.3.10-1ubuntu3.10

However, i have built a new server on Ubuntu 14.04 and seems like php-apc is not available anymore.

Therefore, APC was the lifeserver for my huge traffic (100 k/daily unique visits)

I am little bit confused about caching mechanisms on PHP. The new server includes these packages: php-apc 4.0.2-2build1 php5-apcu 4.0.2-2build1 php5-fpm 5.5.9+dfsg-1ubuntu4.7

phpinfo() gives me "apc" as emulated. As far i understand, APC is replaced with APCu.

https://github.com/cepa/kickasscache I am running this free class for my caching, it really saves alot of cpu/mem in my case. But i can't understand if this is going to same with APCu?

If its not, how can i setup a proper caching? Because my new server has limited resources and i need a solution.

php -v returns

PHP 5.5.9-1ubuntu4.7 (cli) (built: Mar 16 2015 20:47:39)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

Does it means OPcache enabled by default?

martyr
  • 591
  • 1
  • 5
  • 7
  • 2
    APCu is the userdata component of the old APC, without the bytecode caching, because OpCache is now the standard bytecode caching for PHP, but doesn't provide userdata caching – Mark Baker Mar 21 '15 at 20:28
  • @MarkBaker Thanks for the info. Is there any way to get back to old APC functionality? I am thinking about downgrade both my OS, php and other packages. – martyr Mar 21 '15 at 20:44
  • If you downgrade PHP below 5.5, then you'll lose OpCache and be able to use APC as your bytecode cache again – Mark Baker Mar 21 '15 at 21:19
  • Note that PHP 5.4 is no longer actively supported, only security releases, and these will stop after 14th September – Mark Baker Mar 21 '15 at 21:20
  • 2
    @MarkBaker thanks for the great info. I think i found the issue. The whole story was php-apcu package... I have installed it with apt-get, and then upgraded with pecl upgrade. However, if i upgrade to 4.0.7, it kills my memory. i am fine with 4.0.2 now. and i got Segmentation Fault on pecl upgrade but i have ignored it. so bottomline: don't upgrade php-apcu to with PECL. use stock version 4.0.2 with apt :) – martyr Mar 21 '15 at 21:52
  • @MarkBaker why don't you write up your comment as a proper answer here? that seems to cover it. :) – anarcat Jun 04 '15 at 19:10

1 Answers1

29

There is no need for APC (or any of the similar sort of bytecode caching extensions like XCache) as of PHP 5.5 and later. The PHP developers directly integrated what they call OPCache into the core of the product. Not only does this provide greater overall product stability, it is officially supported by the PHP developers.

If you need a specific feature from APC that is not in OPCache (e.g. APCu functionality), then you should start a discussion on the php-dev mailing list.

Finally, a good rule of thumb is to only run versions of PHP that are listed on the php.net homepage. While distros will generally backport security fixes, newer versions of PHP have more useful features. Newer versions of PHP also generally have significant performance benefits that may allow you to bypass needing additional PECL extensions such as APCu.

maddog
  • 520
  • 4
  • 10
  • 1
    May I ask for a source please? http://php.net/manual/en/book.opcache.php says it's bundled with PHP 5.5+ but the content of `/etc/php5/cli/php.ini` and `/etc/php5/apache2/php.ini`, on my fresh install of PHP 5.6+ says it's disabled by default (`;opcache.enable=0`). – Romain Pellerin Jul 23 '16 at 13:11
  • that semi-colon at the beginning of that entry indicates that the line in question is commented out, so IMHO, opcache *is* enabled on your PHP install. If the semi-colon weren't there, then it would, indeed, be disabled, so you're good. – Dave Morton Jul 26 '16 at 08:04
  • You can install `php-apcu-bc` if you are using the data-storage abilities of APC, it installs compatibility functions using APCu. – Ariel Aug 23 '16 at 20:11
  • 2
    @DaveMorton the debian way is to comment out the default, so in this case the default is 0 and the opcache is disabled by default – DooMMasteR Mar 03 '21 at 13:45