php -v command does not work
Solution 1
Make sure that the PHP CLI package is installed. sudo apt-get install php5-cli
.
Also, the PHP binary needs to be added to your path. If you run which php
and get no output, then it is certain that it is not in your path.
Solution 2
The php command is probably not in your path. You can view your path with echo $PATH
. If the directory where the php binary is installed is not in your path, you can set it with export PATH=$PATH:/path/to/php
.
GodAtum
Updated on October 05, 2022Comments
-
GodAtum over 1 year
I have just installed the php5 package on my Debian system using the standard apt-get. The code:
<?php phpinfo(); ?>
works and other php pages work.
But the commands php -v and php -m do not work. It gives an error "-bash: php: command not found".
php5-cli is installed. My path is /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games. I looked into usr/bin and there is no php or php5 file. Not sure where else those can be located?
I ran:
whereis php5 php5: /etc/php5 /usr/lib/php5 /usr/lib64/php5 /usr/share/php5
Dont think any of those are the correct file?
-
MiroslavHave you got PHP CLI installed?
-
-
GodAtum over 11 yearsphp5-cli is installed. My path is /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games. I looked into usr/bin and there is no php or php5 file. Not sure where else those can be located?
-
GodAtum over 11 yearsI ran: whereis php5 php5: /etc/php5 /usr/lib/php5 /usr/lib64/php5 /usr/share/php5
-
jbleners over 11 yearsI'd re-install php5-cli, because the binary (the command line interface) is missing.
-
GodAtum over 11 yearsWhat is the command to re-install? sudo apt-get install --reinstall packagename?
-
Martin over 11 years@GodAtum You can see a list of files installed by a package with
dpkg -L <packagename>