PHP版本:PHP 7.3.16
LINUX版本:7.6php
安裝成功的樣子:git
php -r "phpinfo();" | grep memcache memcache memcache support => enabled memcache.allow_failover => 1 => 1 memcache.chunk_size => 32768 => 32768 memcache.compress_threshold => 20000 => 20000 memcache.default_port => 11211 => 11211 memcache.hash_function => crc32 => crc32 memcache.hash_strategy => consistent => consistent memcache.lock_timeout => 15 => 15 memcache.max_failover_attempts => 20 => 20 memcache.prefix_host_key => 0 => 0 memcache.prefix_host_key_remove_subdomain => 0 => 0 memcache.prefix_host_key_remove_www => 1 => 1 memcache.prefix_static_key => no value => no value memcache.protocol => ascii => ascii memcache.redundancy => 1 => 1 memcache.session_prefix_host_key => 0 => 0 memcache.session_prefix_host_key_remove_subdomain => 0 => 0 memcache.session_prefix_host_key_remove_www => 1 => 1 memcache.session_prefix_static_key => no value => no value memcache.session_redundancy => 2 => 2 memcache.session_save_path => no value => no value
安裝步驟:github
# 下載 memcache 源碼包 wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip # 解壓縮 unzip NON_BLOCKING_IO_php7.zip # 進入解壓後的目錄 cd pecl-memcache-NON_BLOCKING_IO_php7/ # 生成配置文件 /usr/local/php/bin/phpize # 配置 ./configure --with-php-config=/usr/local/php/bin/php-config make make install # 在 php.ini 中添加擴展 extension=memcache # 重啓服務 # 能夠使用下面三種方式中的一種(具體看php的安裝方式) service php-fpm restart kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` systemctl reload php-fpm