PHP7 安装 Memcached
PHP版本:PHP 7.3.16
LINUX版本:7.6
LINUX版本:7.6
安装成功的样子:
php -r "phpinfo();" | grep memcached memcached memcached support => enabled libmemcached version => 1.0.16 memcached.compression_factor => 1.3 => 1.3 memcached.compression_threshold => 2000 => 2000 memcached.compression_type => fastlz => fastlz memcached.default_binary_protocol => Off => Off memcached.default_connect_timeout => 0 => 0 memcached.default_consistent_hash => Off => Off memcached.serializer => php => php memcached.sess_binary_protocol => Off => Off memcached.sess_connect_timeout => 0 => 0 memcached.sess_consistent_hash => On => On memcached.sess_consistent_hash_type => ketama => ketama memcached.sess_lock_expire => 0 => 0 memcached.sess_lock_max_wait => not set => not set memcached.sess_lock_retries => 5 => 5 memcached.sess_lock_wait => not set => not set memcached.sess_lock_wait_max => 150 => 150 memcached.sess_lock_wait_min => 150 => 150 memcached.sess_locking => On => On memcached.sess_number_of_replicas => 0 => 0 memcached.sess_persistent => Off => Off memcached.sess_prefix => memc.sess.key. => memc.sess.key. memcached.sess_randomize_replica_read => Off => Off memcached.sess_remove_failed_servers => Off => Off memcached.sess_sasl_password => no value => no value memcached.sess_sasl_username => no value => no value memcached.sess_server_failure_limit => 0 => 0 memcached.store_retry_count => 2 => 2 Registered save handlers => files user memcache memcached
安装步骤:
# 首先需要安装libmemcached库 yum -y install libmemcached libmemcached-devel # 下载memcached扩展,两个地址任选一 wget https://github.com/php-memcached-dev/php-memcached/archive/php7.zip wget https://pecl.php.net/get/memcached-3.1.3.tgz # 解压 unzip php7.zip or tar zxvf memcached-3.1.3.tgz # 进入到解压后目录 # 准备安装 export PHP_AUTOCONF=/usr/bin/autoconf export PHP_PREFIX=/opt/php /usr/local/php/bin/phpize # 配置 ./configure --with-php-config=/opt/php/bin/php-config make make install # 在php.ini中添加memcached扩展 extension=memcached.so # 可以使用下面二种方式中的一种(具体看php的安装方式) service php-fpm restart systemctl reload php-fpm