Centos设置默认的PHP版本

执行命令查看当前php版本,会得到下面提示,那么我们的目的是将当前php版本更换为php更好版本,以符合开发环境要求。

1、查看当前php版本

[root@izm5e4u1jmuzijy7bp2ct1z ~]# php -v
PHP 5.6.30 (cli) (built: Nov  9 2018 16:03:13) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

2、获取php安装目录

使用命令获取当前可切换的php版本目录有哪些

[root@izm5e4u1jmuzijy7bp2ct1z ~]# find / -name php
/usr/bin/php
/usr/local/php
/usr/local/php/php
/usr/local/php/php/php
/usr/local/php/bin/php
/usr/local/php/include/php
/usr/local/php/lib/php
/usr/local/php5.5/php
/usr/local/php5.5/php/php
/usr/local/php5.5/bin/php
/usr/local/php5.5/include/php
/usr/local/php5.5/lib/php
/usr/local/php7.0/php
/usr/local/php7.0/php/php
/usr/local/php7.0/bin/php
/usr/local/php7.0/include/php
/usr/local/php7.0/lib/php
/usr/local/php7.1/php
/usr/local/php7.1/php/php
/usr/local/php7.1/bin/php
/usr/local/php7.1/include/php
/usr/local/php7.1/lib/php

3、根据目录替换当前最高php版本

那么目前最高安装php版本为7.1,接下来执行命令将当前php版本替换成7.1

[root@izm5e4u1jmuzijy7bp2ct1z ~]# ln -s /usr/local/php7.1/bin/php

无报错标识成功

4、替换php版本

[root@izm5e4u1jmuzijy7bp2ct1z ~]# export PATH=/usr/local/php7.1/bin:$PATH
接下来查看当前php版本是否切换成功

[root@izm5e4u1jmuzijy7bp2ct1z ~]# php -v
PHP 7.1.3 (cli) (built: Nov  9 2018 16:37:45) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.3, Copyright (c) 1999-2017, by Zend Technologies

这样就将php版本切换成功了

阅读 144

Comments