欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Centos7添加epel源并升级php

程序员文章站 2022-04-27 20:08:31
...

Centos7添加epel源并升级php,有需要的朋友可以参考下。


最近在阿里云上入手了一台centos7的服务器,在搭建环境过程中发现php的版本是5.4,且是最新的。可现在php都已经到7了,经查询发现centos为保持稳定性并没用太多的更新源,使得一些软件都过于老。因此为了使用到最新的php版本,我们得在centos中添加一些较新的源。目前在centos系统中较流行的源有epel和remi。接下来我们会添加这两种源来升级php版本。

一、安装源
  1. rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
复制代码
  1. rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
复制代码
二、确认需要安装的php版本
  1. yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
复制代码
三、卸载已经安装的php版本

如果系统中已经安装了较低的php版本,请先卸载掉

  1. yun remove php*
复制代码
四、安装较新的php版本
  1. yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
复制代码
查看php版本
  1. php -v
复制代码
epel, php