公司服务器上的mysql和PHP版本都比较低,用着不舒服也不太安全,所以考虑升级一下。本篇记录升级PHP的步骤,方便以后查找。
首先查看服务器是否安装有旧版本
yum list installed | grep php
查看结果如下
把这些卸载干净
yum remove php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-devel.x86_64 php56w-fpm.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mysql.x86_64 php56w-opcache.x86_64 php56w-pdo.x86_64
之后更新一下yum源
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
之后执行安装
yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
中间我这提示了一个没有发现mcrypt的包,是因为没有epel源,我的解决方法直接把别的服务器上的epel.repo复制过来,就能用了。/etc/yum.repo.d/epel.repo内容如下:
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch http://mirrors.aliyuncs.com/epel-archive/6/$basearch http://mirrors.cloud.tencent.com/epel/6/$basearch http://mirrors.tencentyun.com/epel/6/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 [epel-debuginfo] name=Extra Packages for Enterprise Linux 6 - $basearch - Debug baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch/debug http://mirrors.aliyuncs.com/epel-archive/6/$basearch/debug http://mirrors.cloud.tencent.com/epel/6/$basearch/debug http://mirrors.tencentyun.com/epel/6/$basearch/debug #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=0 [epel-source] name=Extra Packages for Enterprise Linux 6 - $basearch - Source baseurl=http://mirrors.aliyun.com/epel-archive/6/SRPMS
之后在执行上面的安装命令。
安装完成之后,继续安装php-fpm,执行:yum install php70w-fpm
安装完成之后,设置php-fpm开机启动
chkconfig php-fpm on
启动fpm
/etc/init.d/php-fpm start
至此,完成。
原文:https://www.cnblogs.com/dlmg/p/14745003.html