How to install Alternative PHP Cache [APC] on a Linux VPS/Dedicated server !
APC is a free, open, and robust framework for caching and optimizing PHP intermediate code. Here are the most simple steps :
# Login to the server as root
# Download APC
wget http://pecl.php.net/package/APC
eg : wget http://pecl.php.net/get/APC-3.0.15.tgz
# Extract it and move into the directory
tar -xzf APC-3.0.15.tgz
cd APC*
# Locate where php is
which php
This should return something like: /usr/local/bin/php Remember the location of php.
# Create configuration files
phpize
# Compile APC
./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/local/bin/php-config
make
make install
# Install APC into php.ini
You will have to first locate php.ini using the following command
php -i | grep php.ini
This will usually return /usr/local/Zend/etc/php.ini on a server that has Zend optimizer installed. Now edit php.ini and add the APC extension.
vi /usr/local/Zend/etc/php.ini
Scroll down to the bottom and add the fallowing before the lines about the zend optimizer (They start with [Zend])
extension=”/apc_location/apc.so”
# Restart Apache
# Restart Apache