What should I do if linux cannot recognize the php command?

藏色散人
Release: 2023-03-14 17:10:01
Original
3155 people have browsed it

The solution to the problem that Linux cannot recognize the PHP command: 1. Go to Linux to find the location of the PHP file of the integrated environment; 2. Set the PHP environment variable; 3. Execute the update environment variable command.

What should I do if linux cannot recognize the php command?

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

linux cannot recognize the php command. What to do?

How to solve the problem that the php command cannot be used under Linux, test whether to add the php environment variable method:

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 to 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

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

Then you need to go to the environment variable file of the Linux system to set the PHP environment variables, similar to 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:

What should I do if linux cannot recognize the php command?

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 What should I do if linux cannot recognize the php command?. 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