Is APC compatible with PHP 5.4 or PHP 5.5?
Asked Answered
I

14

103

It doesn't seem like APC has been updated to coincide with the php 5.4 release (I wish they would have included APC in PHP core like originally planned).

I can't seem to find any definitive answer to whether current APC works with php 5.4+. I managed to find Ubuntu packages for php 5.4, but php-apc packages won't install.

Ionium answered 8/3, 2012 at 1:20 Comment(4)
I take it you're doing an apt-get install. Have you tried a pecl install?Roxanneroxburgh
Yes, this actually worked. Thank you. And as it turns out, APC works fine with 5.4, in particular, when using the new traits functionality.Ionium
@Darragh [Just letting you know] there's a hefty bounty on this, you might wanna make an answer.Bova
No, It is not. Its last release was at 2012 and that is surly not compatible with newer version of PHPLymphosarcoma
D
164

Zend OPCache included in PHP 5.5

On the 21st March 2013, the PHP 5.5 beta 1 was released including "Zend OPCache" - It looks firmly like this will be the replacement for APC going forward as it is included in the PHP core, and will have to be maintained for each new release.

I would personally advise those who depend on APC for it's opcode caching to test their code with the upcoming built-in opcode cache, and feed back any issues encountered to ensure a stable final release.

I do not know what this means for the future of APC.

APC FOR PHP 5.4+ IS STILL FLAGGED AS BETA

This means the developers do not consider it completely stable. While many people are experiencing no problems at all with the current SVN releases, there is still the odd report of edge cases from people under certain configurations, or under heavy load.

As with everything you would want to use in a production environment, make sure you thoroughly test any release (beta or stable) in development or pre-production environments first. This includes load testing!

As of the 3.1.13 release, commits to the SVN repository have slowed down somewhat and the bug list doesn't have that many recent additions. Make of that what you will.

On 10 December 2012 21:05, Rasmus Lerdorf wrote:

APC is at the point now for 5.4 where I don't think there are any more edge cases than we have in 5.3. Neither is perfect, but it is close enough for the majority of sites.

Anyone with C / gdb skills and some free time is urged to gloss over the bug list and see if they can fix anything, or improve this free open source product that we all rely on.

Alternative solutions exist, Wikipedia provides a list of PHP accelerators.

On the 13th of February 2013, Zeev Suraski announced the availability of the Zend Optimizer+ source code.

There has been quite a lengthy discussion about integrating Zend Optimizer+ into the PHP core in the next major version (the version after 5.5). People may wish to familiarise themselves with Zend Optimizer+ in advance, should this be the case.


Do not use APC 3.1.14

APC 3.1.14 has been removed from PECL downloads due to some serious memory issues that have been discovered but have not yet been tracked down.

If you're already using 3.1.14, you may wish to downgrade until 3.1.15 is released. Remember, this is still beta. If you are using it at all, you are using it at your own risk.

2013-01-02:
APC 3.1.14 is available, adding PHP 5.5 compatibility, in addition to resolving a fair number of other bugs.

Still beta


2012-09-03:
APC 3.1.13 is available, fixing a number of segfaults.


2012-08-16:
An APC 3.1.12 tag has been created, but is still marked as beta, its available on the APC PECL page, as well as the changelog.

Lots of bin_dump related bugs fixed this time around.


2012-07-19:
An APC 3.1.11 tag has been created, but is still marked as beta, its available on the APC PECL page, as well as the changelog. I've been following the relevant mailing lists, and they are still actively working on fixing APC bugs however it is a complex module and not many people seem to be up to the task. This release fixes the nasty stat=0 bugs when including files.


2012-04-11:
An APC 3.1.10 tag was created today, and a beta release of 3.1.10 was placed on the APC PECL page

The changelog states:

  • Add PHP 5.4 support (Dmitry, Anatoliy, Pierre)
  • Fixed bug #22679: Fix apc_bin_dump for constants. Use IS_CONSTANT_TYPE_MASK to handle all the constants, including the unqalified ones (instead of ~IS_CONSTANT_INDEX check)
  • Fixed bug #23822, php crashes on apache restart
Dupin answered 11/4, 2012 at 15:55 Comment(3)
just type: "pecl install apc-3.1.10" and then I had to recompile php so it would update libphp5.soIlario
Been using it sine October 2012 via Apt-get on ubuntu 12. Clean and stable!Diaphony
take a look at this article related to Zend OpCache and APC blogs.oracle.com/opal/entry/using_php_5_5_s and this thread bugs.php.net/bug.php?id=64625Maidamaidan
D
10

As of PHP 5.4.7 and APC 3.1.13 (and even APC SVN trunk as of 2012-09-19), although it is "compatible" it is not stable on servers with heavy load, particularly if you're using PHP-FPM and $GLOBALS. Some of the developer discussions on APC talk about unresolved fringe cases.

I'm answering this question 6 months after it was asked because the problem is still prevalent, and encountering this thread w/o an answer like mine is what made me make the leap to PHP 5.4 w/ APC and get burnt. Hopefully this will help people avoid some pain.

Dottydoty answered 21/9, 2012 at 14:49 Comment(0)
N
6

It appears that the bug "may" have been fixed in the latest revision to the trunk. I've got it working now with PHP 5.4.0.

svn co http://svn.php.net/repository/pecl/apc/trunk/ apc-trunk

cd apc-trunk

phpize

./configure

make

make install

Nephro answered 12/3, 2012 at 23:17 Comment(1)
apc isn't in svn.php.net/repository/pecl anymore. Repo has been converted to Git and can now be browsed at git.php.net/?p=pecl/caching/apc.gitTonguetied
H
5

Well I'm trying for the last few days, and there is no way I can get an opcode cacher to work with php 5.4. Xcache won't compile, and apc will not recognize certain classes when cached. I think this is the error Simon is talking about.

I heard there were some fixes in the trunk, but I also tried the latest trunk sources, but the same errors keep coming back. I think php without a opcode cacher (there is none available right now) is not production worthy. Hopefull the people at apc will fix this asap.

UPDATE!!!

Xcache 2.0.0-rc1 is out and compatible with php 5.4. Enjoy!

Honeyed answered 9/3, 2012 at 2:46 Comment(0)
G
5

No, APC 1.3.9 (and as of this moment, even the svn trunk) isn't compatible with php 5.4.0, I know because I've just spent hours trying to get it to work (tested various svn/php.ini settings/compiler flags/you name it).

This is just ridiculous, APC is one of the most popular PHP extension and you'd expect after weeks of going through 8 PHP 5.4 RC's they'd have the time to get APC to work along side it.

Pathetic.

Gustavogustavus answered 10/3, 2012 at 2:19 Comment(3)
Maybe this is why APC was not included with PHP 5.4 like originally planned.. It seemed to work when I tested it, but, I only tested traits and not any of the other php 5.4 features.Ionium
It seems like the only viable cache/bytecode compiler for php 5.4 is Zend's own zend server package. PHP 5.4 had me kind of excited but without APC or XCache or something, its useless. And this has been the story of PHP for years and years.. always waiting, waiting.. I'm starting to seriously think of taking up some other language.. just not sure what..Ionium
True, the segfault bug was reported way back in Dec last year, and 3 months later it's still not fixed, wtf is the point releasing a 'major upgrade' if it doesn't even work under the most common conditions. [Bug #60462 When APC is enabled segfault - Submitted: 2011-12-07] bugs.php.net/bug.php?id=60462&edit=1Gustavogustavus
T
4

I found apcu http://windows.php.net/downloads/pecl/releases/apcu/

Maybe this is apc for x64 on windows. It (version 4.0.1) worked on my application.

Tabulate answered 14/8, 2013 at 3:26 Comment(0)
D
4

I am using AMPPS with PHP Version 5.5.19. Since some time now exactly from release of PHP 5.5 - APC is replaced with Zend OPCache which is included in PHP 5.5 and up. Now all you have to do to enable "APC" (currently "OPcache") is to edit your php.ini. Before [XDebug] section add the flowing lines:

php.ini

...

[OPcache]

zend_extension=php_opcache.dll

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=24
opcache.max_accelerated_files=4000
opcache.revalidate_freq=3
opcache.fast_shutdown=1

...

Please note that we need to have two instances of:

zend_extension =

One in [OPcache] and one in [XDebug] section. Xdebug is often not provided as default in your xampp/ampps/easyPHP server installation. You might find yourself in a situation where you will need to download Xdebug extension. You can do this easily by using an online application that defines the right Xdebug for your php. Visit http://xdebug.org/wizard.php and follow their simple instructions. Once you have downloaded the right version of Xdebug for your php version - edit the link of your zend_extension in [XDebug] section.

...

[XDebug]
zend_extension = "C:\Program Files (x86)\Ampps\php\ext\php_xdebug-2.2.6-5.5-vc11.dll"
......

Please note! that you have to add OPcache section before XDebug in your php.ini file!!! If you follow me correctly you should have two instances of zend_extension in your php.ini file (one in OPcache and one in Xdebug section).

This works perfectly for Symfony2 framework, and eliminates recommendation message to install and enable APC for your PHP and Xdebug.

Message to those who run symfony 2 and removed the warning message from "web/config.php", but still encounter a problem by running from command line "php app/check.php". If this happens, that means that your console is using a different php.ini file. Change your system PATH varible - make it point to the right php directory (where you have your php.exe file and which is used by your local server).

If you need deeper explanation let me know in the comment below. Regards.

Duwalt answered 28/9, 2014 at 0:38 Comment(3)
I strongly urge the instructions of this answer to be merged with the top answer, so that everyone wanting to implement the OpCache knows exactly how to do so.Corn
If you comment out xdebug "zend_extension" you'll switch it off - it is not necessary. Adding [OPcache] section with "zend_extension" doesn't collide with same parameter from [XDebug] section. Also order of those sections doesn't really matter.Frequentation
Note: [source: php.net/manual/en/opcache.installation.php] If you want to use OPcache with » Xdebug, you must load OPcache before Xdebug.Duwalt
P
3

There seems to be some issues yet to be ironed out. Check out the bugs and you might be able to figure out what is the solution to your particular problem.

I dealt with one such error some hours ago, and it turned out that using APC from the SVN trunk was the way to go. Hope this helps!

Priester answered 8/3, 2012 at 6:35 Comment(1)
Well so far, it seems to be working fine. This is on Ubuntu 10.04 (turnkey LAMP appliance) with PHP 5.4 packages from launchpad.net/~ondrej/+archive/php5. But if something comes up I'll check the bug list. thanks!Ionium
N
3

I've found that you need to clear the opcode cache on each page request otherwise classes that implement interfaces fail to load. This was compiled from the latest svn trunk, Apache 2.4.1, PHP 5.4.0.

Nephro answered 9/3, 2012 at 0:9 Comment(1)
@michiel-thalen you're spot on, that's the issue I was talking about. It's a shame really... Although I've still seen a slight benefit in performance even with resetting the opcode on each load. The user cache still works as intended (in my testing so far).Nephro
A
2

APC - not recommended
Personally I didn't use APC with PHP 5.4 or PHP 5.5, but latest stable APC is not compatible with PHP 5.4, latest beta APC can be used with 5.4 but it is written that still have negative issues with APC.

If you have PHP 5.5
just use Zend Opcache. It is out of the box, so problems are minimum.

If you have PHP 5.4
I recommend XCache. It is fully compatible with PHP 5.4 and 5.5. Actively developed. Last stable version was released 3.5 months ago (10 October 2013). It improves performance even if you use fastcgi.

Ankerite answered 23/1, 2014 at 17:12 Comment(0)
S
1

Zend OPCache is included in PHP 5.5 under the name php_opcache.dll in the php/ext directory. In order to activate it:

  • Add the php_opcahe.dll file as a zend extension in your php.ini configuration file.
  • Use the format zend_extension = path/to/php/ext/php_opcache.dll.
  • Place the zend_extension before the xDebug zend_extension in your php.ini config.
  • Save your php.ini configuration file and restart your server.
Sp answered 12/12, 2013 at 17:20 Comment(0)
F
0

APC has a new version: 3.1.14 since 2 January, which resolves some bugs: http://pecl.php.net/package/APC

However, I have been running PHP 5.4.x with APC 3.1.13 from the dotdeb repository without any issues so far, so for me I would say it's stable. dotdeb has also informed me that they will be including the updated APC in the next release of PHP, which is expected to be 5.4.11.

Friedafriedberg answered 4/1, 2013 at 9:45 Comment(2)
If you're using APC 3.1.14 I advise you to revert to APC 3.1.13 temporarily. Some serious memory related bugs have been discovered which have resulted in the 3.1.14 release being pulled from the downloads section.Dupin
Indeed, I found that the package released by dotdeb for PHP 5.4.11 initially included APC 3.1.14 but that has been reverted to avoid the bugs.Friedafriedberg
M
0

We are experimenting memory free errors (apache segfault) with PHP 5.4.26 and APC 3.1.9. There's an open bug for APC on PHP 5.4.X: https://bugs.php.net/bug.php?id=61934

I recommend not to use this plugin on PHP > 5.3.

Mixture answered 6/6, 2014 at 10:28 Comment(0)
D
0

In XAMPP Version 5.6.3 (PHP 5.6.3) all you have to do in your ini.php is this:

[OPcache]

zend_extension = php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=24
opcache.max_accelerated_files=4000
opcache.revalidate_freq=3
opcache.fast_shutdown=1

[XDebug]

zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.max_nesting_level = 200
xdebug.profiler_append = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
;xdebug.profiler_output_dir = "C:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
;xdebug.remote_enable = 0
;xdebug.remote_handler = "dbgp"
;xdebug.remote_host = "127.0.0.1"
;xdebug.trace_output_dir = "C:\xampp\tmp"

Configuration for symfony2 framework.

Duwalt answered 16/2, 2015 at 20:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.