APC
APC also known as Alternative PhP Cache is an easy way to speed up and optimize performance on your webserver.  We recently installed it on a server that was spiking to 40.00-80.00 load and have seen the server serve files quicker and only spike to a 2.00 – 4.00 load during peak times.  This server was sending out an application on the Zend Framework which is notoriously heavy – so it was good to get such a big speed and optimization boost.

How does apc work? Well for those of you not familiar, everytime a php program is called, a text file is compiled into c code and then executed by the server. On desktop apps, and other programming languages usually this code is pre-compiled and ran everytime. (Think about an EXE file – there is no way to see the lines of code that make up the file.) Well what if we saved this compiled code and skipped the whole step of compiling it every single time a user request the same page. Well apc does this!

To install APC on a redhat/centos based machine is super easy:

yum install php-pear
yum install php-devel
yum install httpd-devel
yum install apr-devel.x86_64

pecl install apc

#Then check /etc/php.d/apc.ini and put:
extension=apc.so
; Options for the apc module
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=32
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.cache_by_default=1
apc.filters = "(kses\.php)|(wp-cache-.*\.html)"

#restart apache
/etc/rc.d/init.d/httpd restart

#check /etc/php.d/apc.ini

After that you can even do a `locate apc.php` and move this file into a web servable directory and you will see charts that will show you all kinds of neat statistics about its performance.

Leave a Comment

Your email address will not be published. Required fields are marked *

Wordpress Management by Creating Digital.