解決CentOS7安裝php7.2之後php -v顯示的版本是5.4的問題
1.查詢系統裡PHP相關的目錄或檔案
find / -name php
/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/php
2.檢視列出的php的版本資訊/usr/local/bin/php -v
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
/usr/bin/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
3.因為5.4.17版本php在/usr/local/bin/下,所以刪除/usr/local/bin/
cd /usr/local/bin/
ls
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
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.ini
Configuration File (php.ini) Path => /usr/local/lib