php -v command does not work

10,223

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.

Share:
10,223
GodAtum
Author by

GodAtum

Updated on October 05, 2022

Comments

  • GodAtum
    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?

    • Miroslav
      Miroslav
      Have you got PHP CLI installed?
  • GodAtum
    GodAtum over 11 years
    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?
  • GodAtum
    GodAtum over 11 years
    I ran: whereis php5 php5: /etc/php5 /usr/lib/php5 /usr/lib64/php5 /usr/share/php5
  • jbleners
    jbleners over 11 years
    I'd re-install php5-cli, because the binary (the command line interface) is missing.
  • GodAtum
    GodAtum over 11 years
    What is the command to re-install? sudo apt-get install --reinstall packagename?
  • Martin
    Martin over 11 years
    @GodAtum You can see a list of files installed by a package with dpkg -L <packagename>