Tuesday, September 17, 2013

Install Memcache and PHP Memcache on cPanel

Step 1: Create work directory
cd /usr/local/src
mkdir memcached-sources
cd memcached-sources
Step 2: Download, compile and install LibEvent
mkdir libevent
cd libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xvfz libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure; make; make install
cd /usr/local/src/memcached-sources/
Step 3: Download, compile and install Memcache
mkdir memcache
cd memcache
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
tar xvfz memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure --with-lib-event=/usr/local/; make; make install
cd /usr/local/src/memcached-sources/
Step 4: Register LibEvent
echo /usr/local/lib/ > /etc/ld.so.conf.d/libevent-i386.conf
ldconfig
Step 5: Download, compile and install PHP Memcache module
mkdir memcache-php
cd memcache-php
wget http://pecl.php.net/get/memcache-3.0.8.tgz
tar xvfz memcache-3.0.8.tgz
cd memcache-3.0.8
phpize
./configure; make; make install
echo >> memcache.so /usr/local/lib/php.ini
service httpd restart
Step 6: Daemonize Memcache
See this article:
http://www.shiftedbytes.com/2013/06/daemonize-memcached-to-run-memcached-as.html