Centos7环境下更新PHP7.2到PHP7.4(WordPress)

升级时需要重新安装扩展,此处仅列出memcache及memcached

【步骤】

1. 备份
服务器快照Snapshot
PHP配置

yum clean all
yum list installed | grep php > /tmp/current-php.txt
cp /etc/php.ini /tmp/php.ini.bak
cp /etc/php-fpm.d/www.conf /tmp/www.conf

 

[可选]
注释掉/etc/php.ini中的extension
;extension=memcached
;extension=memcache
新增/etc/php.d/memcached.ini
; Enable memcached extension module
extension=memcached
新增/etc/php.d/memcache.ini
; Enable memcache extension module
extension=memcache


2. 配置源

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum install yum-utils

yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php74

yum repolist

 

3. 执行Update更新PHP7.4

yum update --nogpgcheck

 

 

4. 检查成果

php -v

 


5. 安装php扩展memcached(选择版本http://pecl.php.net/package,参考https://www.cnblogs.com/flywind/p/6021568.html)

cd /usr/loca/src
wget http://pecl.php.net/get/memcached-3.1.5.tgz
tar zxvf memcached-3.1.5.tgz

cd memcached-3.1.5
/usr/bin/phpize --with-php-config=/usr/bin/php-config

 

# 前提:必须要有libevent库,rpm -qa|grep libevent查看是否安装,版本号2.0以上
# 和libmemcached库(也可直接scp) 参考https://www.cnblogs.com/yhq-qhh/p/9992506.html

./configure --with-php-config=/usr/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl
make && make install

 


6. 安装php扩展memcache(选择版本http://pecl.php.net/package,参考https://www.cnblogs.com/yangxia-test/p/4195222.html)

cd /usr/loca/src
wget http://pecl.php.net/get/memcache-8.0.tgz
tar zxvf memcache-8.0.tgz
cd memcache-8.0
/usr/bin/phpize --with-php-config=/usr/bin/php-config
./configure --enable-memcache --with-php-config=/usr/bin/php-config --with-zlib-dir
make && make install

 

7. 重启/自启服务

systemctl restart php-fpm
systemctl restart nginx
systemctl restart memcached
systemctl enable php-fpm

 

9. 检查phpinfo

 

【可能遇到的问题】


1. -bash: yum-config-manager: command not found
执行

yum -y install yum-utils

然后重试

2. memcached make: *** No targets specified and no makefile found. Stop.
检查是否已安装有libevent库,libmemcached库
参考https://www.cnblogs.com/yhq-qhh/p/9992506.html

【引用参考】

1. Centos7环境下更新PHP7.2到PHP7.4(WordPress)
https://chenyan98.cn/391.html

2. remi仓库官方指引(最强指引!)
https://rpms.remirepo.net/wizard/

3. stackoverflow相关问答
https://stackoverflow.com/questions/50240649/php-7-on-centos-7-4

posted @ 2022-10-11 13:49  风不会停息7  阅读(26)  评论(0)    收藏  举报