下面是一个比较靠谱的php安装步骤:
先删除已有的php版本 ,执行下面的命令删除php
yum remove php-common
然后像安装那样问你是否继续的,输入yes即可
添加 yum 源
CentOS 6.x 的源
# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装 PHP
# yum install --enablerepo=remi,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
注:安装5.6版本为remi-php56,安装5.5版本为remi-php55
错误如下:checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for cc... cc
checking whether the C compiler works... no
configure: error: in /usr/local/src/php540/php-5.4.0': configure: error: C compiler cannot create executables See config.log' for more details.
分析,百度了很长时间终于发现,原来是缺少gcc
所以:
yum install -y gcc就可以了
1:进入终端后查看PHP版本php -v
输出可能如下:
PHP 5.4.35 (cli) (built: Nov 14 2014 07:04:10) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologieswith Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
2:执行下面的命令升级软件仓库
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
3:执行下面的命令删除php
yum remove php-common
然后像安装那样问你是否继续的,输入yes即可
4:安装php 5.6版本(php56w-devel这个不是必需的)
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-MySQL php56w-intl php56w-mbstring
5:重启httpd
service httpd restart
查看最新的版本
php -v
现在应该是5.6了!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)