1.查找系统里PHP相关的目录或文件php
find / -name phpweb
/var/lib/php
/usr/bin/php
/usr/lib64/php
/usr/share/swig/2.0.10/php
/usr/share/php
/usr/include/php-zts/php
/usr/include/php
/usr/local/bin/php
/usr/local/include/php
/usr/local/lib/php
/usr/local/php
/selftemp/php-5.4.17/ext/pcntl/sapi/cli/phpapache
2.查看列出的php的版本信息
/usr/local/bin/php -vvim
PHP 5.4.17 (cli) (built: Sep 21 2017 10:27:13)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologiesapi
/usr/bin/php -vsocket
PHP 7.2.6 (cli) (built: Jun 2 2018 07:49:42) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies函数
3.由于5.4.17版本php在/usr/local/bin/下,因此删除/usr/local/bin/目录下的全部PHP相关的目录或文件ui
cd /usr/local/bin/spa
lsserver
courierauthconfig c_rehash parl par.pl peardev phantomjs phar.phar php-cgi phpize scandeps.pl zipdetails
crc32 openssl parldyn pear pecl phar php php-config pp tkpp
rm -rf ./php
rm -rf ./php-cgi
rm -rf ./php-config
4.环境变量中加上正确PHP版本的路径vim /etc/profile文件末尾加上export PATH="/usr/local/php/bin:$PATH"
5.执行
source /etc/profile
6.若是不出错则再次查看php版本若是是7则说明成功了
php -v
PHP 7.2.6 (cli) (built: Jun 2 2018 07:49:42) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies
7.若是报错没有sokcet函数,stream_socket_server() has been disabled for security...
编辑php.ini把disable_functions=...中找到stream_socket_server()、stream_socket_client,删除掉,从新启动web组件
----------------------------------------------------------------------------------------------------
其余可能用到的知识点:
查找php.ini配置文件 :find / -name php.ini
/etc/php.ini
查看PHP加载的是哪一个配置文件,这个获取的是系统内的php.ini 的位置。不是网页apache加载的php.ini文件php -i | grep php.iniConfiguration File (php.ini) Path => /usr/local/lib