Whole document tree
    

Whole document tree

PHP extensions

5. PHP extensions

There are many different extensions available for php, which can be added in your php.ini

5.1. APC (Alternative PHP-cache)

5.1.1. What is APC

Quoting www.apc.communityconnect.com/

APC is the Alternative PHP Cache. It was conceived of to provide a free, open, and robust framework for compiling and caching php scripts. APC was conceived of to provide a way of boosting the performance of PHP on heavily loaded sites by providing a way for scripts to be cached in a compiled state, so that the overhead of parsing and compiling can be almost completely eliminated. There are commercial products which provide this functionality, but they are neither open-source nor free. Our goal was to level the playing field by providing an implementation that allows greater flexibility and is universally accessible. We also wanted the cache to provide visibility into it's own workings and those of PHP, so time was invested in providing internal diagnostic tools which allow for cache diagnostics and maintenance. Thus arrived APC. Since we were committed to developing a product which can easily grow with new version of PHP, we implemented it as a zend extension, allowing it to either be compiled into PHP or added post facto as a drop in module. As with PHP, it is available completely free for commercial and non-commercial use, under the same terms as PHP itself. APC has been tested under PHP 4.0.3, 4.0.3pl1 and 4.0.4. It currently compiles under Linux and FreeBSD. Patches for ports to other OSs/ PHP versions are welcome.

From the authors point of view:

The author made some performance-Tests with apc and it was real surprise. A PHP-Webpage with mysql-queries in a loop (total 10 queries) was more than 50% faster

Contra APC: If you have other users on the system coding php they maybe are not comfortable with APC, because the changes are all ignored unless you reset the cache or restart Apache. The other way, namly that APC checks the php-script for a newer version befor every run costs speed.

5.1.3. Building and installing


cd /usr/local

tar -xvzf apc-1.1.0pl1.tar.gz

cd apc-1.1.0pl1

./configure --enable-apc --with-php-config=/usr/local/bin/php-config

make
make install

cp modules/php_apc.so /usr/local/lib/php/extensions

echo 'zend_extension="/usr/local/lib/php/extensions/php_apc.so"' >> /usr/local/lib/php.ini
echo “apc.mode = shm” >> apc.mode = shm

Restart your Apache-Webserver. Try it out, create a php-file with the following content:


<?php
apcinfo();
?>