In this tutorial we will cover the steps needed to install Alternative PHP Cache on your CentOS 6.4, Debian or Ubuntu platform.

Requirements

  • CentOS 6.4, Debian or Ubuntu installed on your computer/server
  • SSH access (Command line access to the server)
  • root privileges
  • Basic skills for working on a Linux environment
  • LAMP installed on the server

APC (Alternate PHP Cache) is an free and open source cache for PHP code. It is a framework that caches the output of the PHP compiler inside the shared memory (RAM), thus reducing parsing and disk I/O time.

Install APC

Prior the procedure we will need to make sure that some dependency packages are already installed:

CentOS 6.4

Debian/Ubuntu

After that we can use the default package manager for the APC installation:

During the installation procedure you will be prompted to answer few questions:

Unless you know what exactly they refer to, go ahead and set the default values by hitting Enter for them.

At the end of the installation you will be informed that the APC module should be added manually inside the php.ini file:

configuration option "php_ini" is not set to php.ini location
You should add "extension=apc.so" to php.ini

Configure APC

An easy way to find the exact location of the php.ini file is using the PHP information command:

The output should be similar to the following one:

Open the php.ini file and add the extension line at its end:

When ready we can restart the Apache service in order for the changes to take effect:

CentOS 6.4

Debian/Ubuntu

Test the functionality of the service

We can test the functionality of the service by creating a test PHP info file inside the Apache web root folder (usually this is /var/www/):

containing the following lines:

Save the file and open it using your browser:

An easy way to find your server's IP address is to execute the following command:

Default PHP information page should be displayed on your end and an APC section should be included inside:

APC administration panel

APC provides an administrative section which can be used for status and performance checking. Copy the page from its default location inside the the Apache web root folder:

CentOS 6.4:

Debian/Ubuntu:

ww/

After that open the file and change the default page login credentials:

Save the file and open it through your browser: