PHP opcode caching
Install APC Caching
One of the most common occurences today of webserver load is the ever-so-needed PHP. PHP is usually a must have – often not a way around it. It’s just too popular and mainstream in todays Internet. How would we reduce load caused by PHP? Well, what we CAN do is install some caching. I prefer APC myself – it’s easy, fast and it plain works. The problem with APC is you cannot run Zend and Ioncube with. This usually crosses it off shared hosting servers.
APC works by caching PHP opcodes and storing them in memory (RAM). This usually significally reduces load caused on your server caused by PHP applications. For this example, we will assume you are running PHP 5.2, Apache webserver and CentOS Linux operating system.
Onto installing APC!
The first way we can do is if you have php-pear installed. Then we can use PECL
First thing you can try is installing straight from pecl. This won’t work depending on things such as /tmp hardening, SELinux status, etc. I’ll explain how to get around that and install APC for PHP caching in a moment.
pecl install apc
nano /usr/local/lib/php.ini
service httpd restart
Of course, remove the Zend-related lines. If your php.ini is in a different spot, please change the above. If you don’t have nano installed, use vi – or whatever editor you DO have installed.
A lot of times installing APC for PHP caching doesn’t work with the above. These reasons can be /tmp is noexec, SELinux is blocking the C compiler, etc. So, what I do is below:
pecl download apc
cd apc*
phpize
./configure –with-apc
make && make install
Now, if everything worked above – you need to again uncomment the Zend lines in your php.ini (/usr/local/lib/php.ini for cPanel users) and add extension=apc.so to your php.ini as well. Then you can:
service httpd restart
php -i | grep -i apc
Now, APC caching for PHP should be enabled! Congratulations and I hope the PHP induced load on your Linux webserver is now dropping steadily.

