How to solve the problem that the linux php -v command cannot be found

藏色散人
Release: 2023-03-13 10:08:01
Original
3069 people have browsed it

linux php -v command cannot find the solution: 1. Find the location of the php file in linux; 2. Set the php environment variable in the environment variable file of the linux system; 3. Execute and update the environment variable Just order.

How to solve the problem that the linux php -v command cannot be found

The operating environment of this article: linux5.9.8 system, PHP5.4.26 version, DELL G3 computer

php command cannot be used under linux How to solve, test whether to add php environment variables:

is as follows: enter php -v to display the php command not found

[root@iz8vbhc4d7zoazstpw7gw8z ~]# php -v -bash: php: command not found
Copy after login

1. First go to linux Find the location of the php file of the integrated environment

[root@iz8vbhc4d7zoazstpw7gw8z /]# cd phpstudy/server/php/ [root@iz8vbhc4d7zoazstpw7gw8z php]# ls bin do_not_delete etc include lib php sbin var [root@iz8vbhc4d7zoazstpw7gw8z php]# cd bin/ [root@iz8vbhc4d7zoazstpw7gw8z bin]# ls phar phar.phar php php-cgi php-config phpize [root@iz8vbhc4d7zoazstpw7gw8z bin]# pwd /phpstudy/server/php/bin
Copy after login

Get the location of the bin directory of php as above. I use phpstudy integrated environment for linux

Then I need to go to the environment variable file of the linux system to set it PHP environment variables are similar to those in Windows. The file is in the etc

[root@iz8vbhc4d7zoazstpw7gw8z ~]# cd /[root@iz8vbhc4d7zoazstpw7gw8z /]# vim etc/profile
Copy after login

under the root directory/ and then start editing the configuration file of the environment variables

As shown in the figure:

How to solve the problem that the linux php -v command cannot be found

will be found Put the path to the bin directory of php and add these two lines of code here;

If you need to add other environment variables, just find the directory where the executable file is located, append a colon (":") and the directory. Okay, then save and exit

Execute the update environment variable command:

[root@iz8vbhc4d7zoazstpw7gw8z /]# source /etc/profile
Copy after login

Then enter php -v and it will be OK

[root@iz8vbhc4d7zoazstpw7gw8z /]# php -vPHP 5.4.26 (cli) (built: Sep 7 2017 12:52:40)Copyright (c) 1997-2014 The PHP GroupZend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies
Copy after login

It works!

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to solve the problem that the linux php -v command cannot be found. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!