一、删除旧版本 如果已经安装过php就先删除之前的版本。检查方法如下: yum list installed | grep php 然后将安装的包进行删除 比如 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64 具体根据显示的安装列表的名称进行相应的删除 二、安装新版版 1. 更新yum安装包 CentOS 7.x rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm CentOS 6.x rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm CentOS 5.x rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm 2. 通过云进行php和其他组件的安装 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 yum install php70w-fpm 其他需要的组件在自行安装。 三、其他版本php安装 如果想安装php5.5或者5.6版本,将上面的php70w替换为php55w或者php56w就可以了。
方案1
-
CENTOS安装PHP7
-
-------------------
-
-
方案2
1.检查当前安装的PHP包
- yum list installed | grep php
如果有安装的PHP包,先删除他们
- yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
配置yum源
追加CentOS 6.5的epel及remi源。
12# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm以下是CentOS 7.0的源。
12# yum install epel-release# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm使用yum list命令查看可安装的包(Packege)。
1# yum list --enablerepo=remi --enablerepo=remi-php56 | grep php安装PHP5.6.x
yum源配置好了,下一步就安装PHP5.6。
1# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof用PHP命令查看版本。
123456# php --versionPHP 5.6.0 (cli) (built: Sep 3 2014 19:51:31)Copyright (c) 1997-2014 The PHP GroupZend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologieswith Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologieswith Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans安装PHP-fpm
- yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm

本文提供两种在CentOS上安装不同版本PHP的方法。一种是通过Webtatic源安装PHP7,包括删除旧版本、更新yum包及安装所需组件;另一种是通过EPEL和REMI源安装PHP5.6,同样涉及源配置与组件安装。
1694

被折叠的 条评论
为什么被折叠?



