APC Opcode Cache
alan | 04 November, 2007 13:01Armen recommended me to install APC opcode cache system to improve PHP performance on our servers. APC seems to be better for PHP5 and might be implemented as a default feature in PHP6. Pages are displayed faster and system load is better, but I shortly noticed that there is a common "White page of Death" problem with APC. This problem causes all pages to be displayed as a blank white page. Discarding cache contents (or simply restarting Apache) solves the problem.
A small cron script with curl checks if APC is death:
| #!/bin/bash # Needs: curl, apache or apache2 # Prevent's APC's white pages of death CHK="`/usr/bin/curl -s <YOUR SITE URL>`" if [ -z "$CHK" ]; then echo "APC is dead..." if [ -f /usr/sbin/apache2ctl ]; then /usr/sbin/apache2ctl restart elif [ -f /isr/sbin/apachectl ]; then /usr/sbin/apachectl restart else echo "No Apache?" fi else echo "Status OK" fi |
Here's the short installation instructions for Debian Etch with Apache 2.0 and PHP5:
| # wget http://pecl.php.net/get/APC-3.0.15.tgz # tar -zxf APC-3.0.15.tgz && cd APC-3.0.15/ # apt-get update && apt-get install apache2-dev php5-dev # phpize && ./configure --enable-apc --enable-apc-mmap --with-apxs=/usr/bin/apxs2 --with-php-config=/usr/bin/php-config # make && make install # echo "extension=apc.so" >> /etc/php5/apache2/php.ini # apache2ctl restart |
Finished! I also recommend to copy shipped `apc.php` file to an authenticated web accessed directory to monitor APC status.
Posted in
FOSS .
Comment: (2).
Trackbacks:(0).
Permalink
«Next post |
Previous post»




1. Alan Baghumian | 01/07,2008 at 07:51
It seems that this problem has been addressed in 3.0.16 :-)
2. Armin ranjbar | 11/14,2007 at 08:55
dear alan ,
humm!
mount /dev/ram0 /APC_CACHE_DIR -t ramfs
also note that White page problem appear when you are using WP-Cache as well as APC .