Installing APC on Redhat is as simple as:
[user@server directory]# yum install php-pecl-apc
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]# yum install memcached
[user@server directory]# /etc/init.d/memcached startThe PHP Memcached module can be installed through YUM as well:
[user@server directory]# yum install php-pecl-memcache
Now to configure PHP to use Memcached to store the session information we need to edit our /etc/php.d/memcache.ini file and jump to the bottom of the file where we uncomment the following lines by removing the preceeding semicolon (‘;’):
; Options to use the memcache session handler
; Use memcache as a session handler ; session.save_handler=memcache ; Defines a comma separated of server urls to use for session storage
;session.save_path=“tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15”
So that it now looks like this:
; Options to use the memcache session handler
; Use memcache as a session handler session.save_handler=memcache ; Defines a comma separated of server urls to use for session storage
session.save_path=“tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15”
That just leaves us to restart the Apache/HTTPd process:
[user@server directory]# /etc/init.d/httpd restart
You are now up and running with Memcached PHP sessions and APC served PHP.