In this how to i will describe how to install memcached on your server with PHP Extension. memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. My server is running CentOS 5.3 with CPanel.
1) Install memcached.
Enable rpmforge respository to install latest memcached rpm using yum.
For i386 / i686For x86_64Use yum to install memcached
As soon as memcached installation completed, edit options for memcached in /etc/sysconfig/memcached to meet your need.yum -y install memcachedSave the file. All options can be seen by using following commandvi /etc/sysconfig/memcached
PORT=”11211″ #define on which port to urn
USER=”nobody” #same as apache user
MAXCONN=”1024″ #maximum number of connections allowed
CACHESIZE=”64″ #memory used for caching
OPTIONS=”" #use for any custom options
Start memcachedmemcached -hto check the running status of memcached/etc/init.d/memcached start
Starting Distributed memory caching (memcached): [ OK ]2) Install PHP Extension./etc/init.d/memcached statusand
memcached (pid 6475) is running…
netstat -anp | grep 11211
tcp 0 0 :::11211 :::* LISTEN 6475/memcached
udp 0 0 0.0.0.0:11211 0.0.0.0:* 6475/memcached
Download and install latest stable memcache version from PECL.To find out your php.ini location, execute following commandmemcache.so will be install in php modules directory, now enable memcache.so extension in php.inicd /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
phpize
./configure
make
make install
save the file and restart httpd server.php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
vi /usr/local/lib/php.ini
extension = “memcache.so”
To check is memcache extension loaded in php, execute following command./etc/init.d/httpd restart
This information can also be seen using phpinfo().php -i | grep memcache
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.default_timeout_ms => 1000 => 1000
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => standard => standard
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user sqlite memcache
PWD => /usr/src/memcache-2.2.5
_SERVER["PWD"] => /usr/src/memcache-2.2.5
_ENV["PWD"] => /usr/src/memcache-2.2.5
Mô Tả: Tăng Năng Xử lý cho các ứng dụng .