由于PHP的memcached错误,我浪费了一整天的时间。(Note: The original statement seems to be in Japanese, not Chinese. However, I provided the requested paraphrase in Chinese.)

目前的状况

当进入页面时,会出现以下警告提醒。

using touch command with binary protocol is not recommended with libmemcached versions below 1.0.18, please use ascii protocol or upgrade libmemcached

环境。

CentOS Linux 发布版 7.4.1708
nginx/1.10.2
PHP 7.1.10 (fpm-fcgi)
php-fpm

想做的事情

php -i | grep memcache

当检查libmemcached的版本时,发现是1.0.16,所以想将版本升级到1.0.18。

积分

在过去的环境中,我们通过yum安装php-pecl-memcached,但得到的版本只有1.0.16。

yum -y install memcached

yum -y install --enablerepo=remi,remi-php71 php php-devel php-mbstring php-pdo php-gd php-mcrypt php-fpm php-mysqlnd php-opcache php-apcu php-xml php-tokenizer php-openssl php-pecl-memcached

应对

停止使用php-pecl-memcached

# memcached

yum -y install memcached

wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar xvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure
make
make install
cd ../

wget http://pecl.php.net/get/memcached-3.0.3.tgz
tar xvf memcached-3.0.3.tgz
yum -y install autoconf
yum -y install zlib-devel
cd memcached-3.0.3
phpize
./configure --with-libmemcached-dir=/usr/local/ --disable-memcached-sasl
make
make install
cd ../

systemctl enable memcached

在/etc/php.ini中加入以下内容

extension=memcached.so

結果()

# php -i | grep memcache

memcached
memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.default_binary_protocol => 0 => 0
memcached.default_connect_timeout => 0 => 0
memcached.default_consistent_hash => 0 => 0
memcached.serializer => php => php
memcached.sess_binary_protocol => 1 => 1
memcached.sess_connect_timeout => 0 => 0
memcached.sess_consistent_hash => 1 => 1
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 => 2000 => 2000
memcached.sess_lock_wait_min => 1000 => 1000
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_persistent => 0 => 0
memcached.sess_prefix => memc.sess. => memc.sess.
memcached.sess_randomize_replica_read => 0 => 0
memcached.sess_remove_failed_servers => 0 => 0
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 memcached
session.save_handler => memcached => memcached

警告不再出现了!

广告
将在 10 秒后关闭
bannerAds