How to install APC (Alternative PHP Cache)

APC gives our server a huge performance boost. It is a free and robust framework for caching and optimizing PHP intermediate code.

The installation steps are given below :

1. Login to the server as root
2. Download APC. You will get the latest tar file from the site http://pecl.php.net/package/apc 

     wget http://pecl.php.net/get/APC-3.0.14.tgz

3. Extract and move into the directory

    tar -xzvf APC-3.0.14.tgz
cd APC-3.0.14

4. Locate the location of phpize

    whereis phpize

It should look like:

    phpize: /usr/bin/phpize

5. Run the same whereis command for php-config and apxs. Next type:

    /usr/bin/phpize

6. Compile APC

    ./configure –enable-apc –enable-apc-mmap –with-apxs –with-php-config=/usr/local/bin/php-config
make
make install

The “make install” command will return the location of the apc.so extension. Note down the location as we need it later.

7. Install APC into php.ini. For that we need to edit php.ini and add the APC extension.

          vi /usr/local/lib/php.ini

Add the following lines in php.ini

       extension_dir = /usr/local/lib/php/extensions/no-debug-non-zts-20060613 (We have already note this down after the                                                                                                                                                                             installation)
extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=128
apc.ttl=300
apc.user_ttl=300
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.stat = 1
apc.rfc1867=1
apc.rfc1867_prefix=”upload_”
apc.rfc1867_name=”APC_UPLOAD_PROGRESS”
apc.rfc1867_freq=”100k”

8. Restart Apache

        service httpd restart

You can check whether APC is successfully installed by checking the phpinfo page.

Both comments and pings are currently closed.

Comments are closed.