Home > Backend Development > PHP7 > What should I do if there is no version of php-v after installing php7.2?

What should I do if there is no version of php-v after installing php7.2?

藏色散人
Release: 2023-02-18 09:04:02
Original
2383 people have browsed it

Solution to the problem that php-v has no version after installing php7.2: 1. Search for PHP-related directories or files in the system; 2. View the version information of php listed; 3. Delete all files in the bin directory PHP related directories; 4. Add the path to the correct PHP version to the environment variable.

What should I do if there is no version of php-v after installing php7.2?

The operating environment of this article: centos7 system, php7.2, Dell G3 computer.

What should I do if there is no version of php-v after installing php7.2?

Solve the problem that after CentOS7 installs php7.2, the version displayed by php -v is 5.4

1. Find the PHP-related directories or files in the system

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
Copy after login

2. Check the version information of php listed

/usr/local/bin/php -v
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 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
Copy after login

3. Because the 5.4.17 version of php is under /usr/local/bin/, delete all PHP related files in the /usr/local/bin/ directory Directory or file

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
Copy after login

4. Add the path to the correct PHP version to the environment variable

vim /etc/profile
文件末尾加上 export PATH="/usr/local/php/bin:$PATH"
Copy after login

5. Execute

source /etc/profile
Copy after login

6. If no error occurs, check the PHP version again If it is 7, it means success

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
Copy after login

7. If the error is reported and there is no sokcet function, stream_socket_server() has been disabled for security...

Edit php.ini and set disable_functions=... Find stream_socket_server(), stream_socket_client, delete them, and restart the web component

-------------------------------- -------------------------------------------------- --------------------

Other knowledge points that may be used:

Find the php.ini configuration file: find / - name php.ini

/etc/php.ini

Check which configuration file PHP loads. This gets the location of php.ini in the system. It is not the php.ini file loaded by the web apache

php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Copy after login

Recommended study: "PHP Video Tutorial"

The above is the detailed content of What should I do if there is no version of php-v after installing php7.2?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template