Centos system install memcached extension for php 1. install memcached through yum
Yum-y install memcached
# Run the following command after installation:
Memcached-h
# The memcached help message indicates that the installation is successful.
2. join the startup service
Chkconfig -- level 2345 memcached on
3. configure Memcached
Vim/etc/sysconfig/memcached
# The file content is as follows and can be modified as needed:
PORT = "11211" # PORT
USER = "root" # USER name
MAXCONN = "1024" # maximum number of connections
CACHESIZE = "64" # memory size
OPTIONS = "" # Additional parameters
4. install libmemached
Wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
Tar-zxvf libmemcached-1.0.16.tar.gz
Cd libmemcached-1.0.16
./Configure-prefix =/usr/local/libmemcached-with-memcached
Make & make install
Error: g ++: command not found
Yum-y install gcc + gcc-c ++
After making clean, run make & make install again.
5. install php-devel
Yum install php-devel
6. install PHP Memcached extension
Wget http://pecl.php.net/get/memcached-2.1.0.tgz
Tar-zxvf memcached-2.1.0.tgz
Cd memcached-2.1.0
/Usr/local/php/bin/phpize
. /Configure-enable-memcached-with-php-config =/usr/local/php/bin/php-config-with-zlib-dir-with-libmemcached-dir =/usr /local/libmemcached-prefix =/usr/local/phpmemcached
Make & make install
Error: memcache support requires ZLIB solution
Yum install zlib-devel
Record the prompt after successful installation, similar:
Installing shared extensions:/usr/lib/php/modules/
7. added extended extension configuration file
Vi/etc/php. d/memcached. ini
Add 1 line
Extension = memcached. so
Finally, verify whether the installation is complete.
Php-m | grep memcached
Memcached should be displayed
8. restart nginx/amapche, restart php-fpm, and use phpinfo () to check whether the memcached module is successfully installed.
**************************************** **************************************** ********
Memcached can be started but cannot be connected using php (the browser opens the page containing memcached, and firebug reports Error 500)
1. change SELINUX = enforcing to SELINUX = disabled.
2. try to use telnet localhost 11211 or telnet 127.0.0.1 11211 on the terminal to connect to the memcached server.
If bash: telnet: command not found is prompted
Execute: yum install telnet-y and return to the browser again to try to open it.
Test script:
addServer('127.0.0.1', 11211);$m->set('foo', 200);var_dump($m->get('foo'));?>