How to install the memcached binary on CentOS
I always need to install the memcached on my linux servers like fedora or centos. On fedora box installing the memcached is very easy through yum install. But Centos installing and using memcached is not so easy.
For my Ruby on Rails and PHP applications I always need to install the memcached on server. Here I am going to give you the steps for installing the memcached.
Very important note: you need to install the gcc compiler for memcached binary installation. Using the memcached with php installation you need the phpize and php-pecl-memcached installed. follow my steps and memcached binary installtion.
# yum install gcc*
# cd /usr/src
# wget http://pecl.php.net/get/memcache-2.2.5.tgz
# tar zxvf memcache-2.2.5.tgz
# cd memcache-2.2.5
# make install
For checking the php.ini file path use following command.
php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
or your php.ini file will be following location
# vim /etc/php.ini
Put following line in that file
extension = “memcache.so”
Restart the apache server
# /etc/init.d/httpd restart
To check is memcache extension loaded in php, execute following command.
#php -i | grep memcache
After restarting the machine memcache need to restart. For that us ( Use this step for only Admin Adserver Box)
# vi /etc/rc.local
Put following contect in to rc.local file (file location – /etc/rc.local)
# memcached -d -p 11211 -u nobody -c 1024 -m 1024