Skip to content

How to Configure Memcache For PHP in Fedora

How to Configure Memcache For PHP in Fedora
© fry_theonly

Memcached is an awesome memory object caching system that allows you to store highly requested data in RAM, across a network of servers. This saves time and money as users do not have to hit their Mysql (or SimpleDB) database. It is pretty simple to configure memcache for PHP in Fedora. The first thing you need is a library called 'libevent'.

Next, you want to install memcached. Yum makes this very simple, as all you have to do is type: yum install memcached. When yum is finished, you should run it as a daemon. To do this as simply as possible, you type: memcached -d -u apache. This will make memcache run as a daemon under user 'apache'. Finally, to get the Memcached extension for PHP installed, you use yum and type: yum install php-pecl-memcache.

Configuring Memcache on Cloud Servers

Configuring Memcache on Cloud Servers
© Ed Yourdon

Memcache is a high-performance, distributed memory object caching system that can be used to speed up dynamic web applications, and as such it is very useful in cloud computing. Configuring memcache on cloud servers requires that you begin with session management and build up a chaching daemon to store PHP sessions in a load balanced environment.

There are several steps to follow in ordered to easily install and make it available in LAMP. In the case that you have a cluster of web servers behind a load balancer like Elastic Load Balancer (ELB), for example, without sticky sessions then persistent PHP session storage will definitely become a matter of concern as you won't be able to store sessions across multiple servers. You can usually save the user sessions in RAM instead, where all your servers can access, and which is usually memcached.

Configure Memcache on CakePHP Ubuntu

Configure Memcache on CakePHP Ubuntu
© Lars Plougmann

The following is a walk-through on how to configure memcache functionality in cakePHP on Ubuntu flavor. First you must have Apache, PHP, mysql and cakePHP properly installed and configured. There will be two steps involved: Installation of memcache on system, and configuration of memcache. There are different methods for installation, but the easiest way is through package.

This line will install memcache on ubuntu and will start it: raj@raj-VirtualBox: ~$ sudo apt-get install memcache. However, installing and starting it is not enough to enable it for websites. It also has to be configured. To do this with cakePHP, you use the line: raj@raj-VirtualBox:~$ sudo apt-get install php5-memcache. Once this is done, you want to open /config/core.php and edit set Configure::write('Session.save', 'php'). This command tells cake to let PHP handle sessions.