I want to use APC-based caching for my PHP 5.3 application, now that I have more memory. How do I do that? asked 17 Dec '11, 03:11 neeravk |
Admin note: this procedure will not produce a working APC installation on our servers, since a) APC doesn't work with php-cgi, and b) you can't load custom PECL extensions with php-fastcgi. If you need APC, then see the second answer for instructions on how to build a Nginx + php-fpm stack. You can do that by installing the APC PECL extension :). Here is the list of commands to do that:
Script executed successfully but APC is not listed in phpinfo(), any idea what can be wrong?
(30 Dec '11, 07:40)
Naz
Hi, It's hard to say without looking at your app. Could you open a ticket, so we can take a look?
(30 Dec '11, 07:59)
todork
for some reason "extension = apc.so" was not included inside php.ini, thanks for pointing it out.
(30 Dec '11, 08:38)
Naz
I've got APC running and it seems to be functioning but when I browse to the apc.php file to see the stats nothing seems to be displayed?
(15 Feb '13, 13:55)
peterhough
1
If you are not using fastCGI, APC will not work at all (everything is re-initialized on each request). If you are using FastCGI, then APC will work, but each thread will have its own separate cache, making APC caching inefficient and much less effective (everything may need to be cached up to six times before it's really cached, and this also bloats memory consumption). This is unfortunately just how APC works, as per this bug report, and this stackoverflow discussion. This guide shows how to install a PECL extension such as APC. The actual operation of APC itself is up to the APC maintainers, and in their words, "this behaviour is the intended one as of now".
(18 Feb '13, 21:22)
ryans ♦♦
Thanks for your comment ryans. However, looking at the bug report "It works fine if you use spawnfcgi or php-fpm". Is using a process manager possible or would I need to build my own PHP worker as a custom app?
(22 Feb '13, 05:04)
peterhough
showing 5 of 6
show 1 more comments
|
In response to my comments on the answer above I thought I'd clarify how I've got APC working with PHP-FPM. I'm by no means an expert at this but managed to fumble my way through. Using the guide posted on question 930 as a base I installed nginx as a custom webapp and a custom PHP stack. The only issue I encountered was that I also needed to install libmcrypt in my home directory. The PHP configure line I used tries to match a standard Webfaction PHP install:
With this set up I've a custom nginx webapp running a custom install of PHP with FPM enabled. APC is caching my files and the stats display correctly. Similar to how the Webfaction php worker script works I also need to installed a cronjob to restart nginx & PHP if the server went down. Both nginx and PHP need to be configured to create PID files and you'll also init scripts for both nginx and php. The init scripts need to fail if the PID exists so the nginx one will need modifying to do this (use the PHP one as an example). The script to do run on cron might look like the following:
I hope that helps other fumble their way through this set-up. Pete. answered 11 Apr '13, 04:23 peterhough seanf |