Installing APC on Debian or Ubuntu is as simple as:
user@server:/directory/$ sudo apt-get install php-apc
Now let us reboot the Apache process to enable our new cache:
user@server:/directory/$ sudo /etc/init.d/apache2 restart
APC should now be ready to run on your server. Try running the following command to verify it is setup; you should get something in response like mine:
user@server:/directory/$ php -r ‘phpinfo();’ | grep ‘apc’
apc
MMAP File Mask => /tmp/apc.s5jA6w
apc.cache_by_default => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => On => On
apc.enabled => On => On<…SNIP…>
Now lets move onto installing Memcached, which again is very simple:
user@server:/directory/$ sudo apt-get install memcached
user@server:/directory/$ /etc/init.d/memcached start
The PHP Memcached module can be installed through Apt-Get as well:
user@server:/directory/$ sudo apt-get install php5-memcache
Now to configure PHP to use Memcached to store the session information we need to edit our /etc/php5/apache2/php.ini file and find the lines like the following:
session.save_handler = files
;session.save_path =
and change them so that they now look like this:
session.save_handler = memcache
session.save_path = “tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15″
That just leaves us to restart the Apache2 process:
user@server:/directory/$ /etc/init.d/apache2 restart
You are now up and running with Memcached PHP sessions and APC served PHP.

