7/29/2008

Install PHP-MemCache On CentOS 5.2

I'm a linux newbie, but I want to speed up my webserver access, after googling around for days, I decided to try the php-memcache and I find most of my installation steps ini howtoforge.com. Here is what I did :

Install rpmforge repo
$ wget
http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-*.rpm
$ rpm --install rpmforge-release-*.rpm

Install memcached:
$ yum install --enablerepo=rpmforge memcached
test if memcached is running:
$ memcached -m 512 -u nobody -vv

start up the memcached daemon on as many spare machines as you have. The daemon has no configuration file, just a few command line options, only 3 or 4 of which you'll likely use:
$ ./memcached -d -m 2048 -l 10.0.0.40 -p 11211 -u nobody

This starts memcached up as a daemon, using 2GB of memory, and listening on IP 10.0.0.40, port 11211. The -m switch specifies the amount of memory in megabytes. The -l switch specifies the IP to listen on and finally the -p switch specifies the port to listen on. The default port is 11211 and if your machine has just 1 IP you can omit the -l parameter.

Install PHP MemCache extension
$ cd /usr/src/
$ wget http://pecl.php.net/get/memcache-2.2.3.tgz
$ tar -xvf memcache-2.2.3.tgzcd memcache-2.2.3
$ phpize && ./configure --enable-memcache && make
Copy the file memcache.so to the default module directory.
$ cp /usr/src/memcache-2.2.3/modules/memcache.so
/usr/lib/php/modules/memcache.so

Edit php.ini
$ nano /etc/php.ini
And add this line ini php.ini
extension=memcache.so
Restart Apache2
$ /etc/init.d/httpd restart
Now the php-memcache is installed

No comments: