As akirk has hinted, the PHP which runs stuff on your webserver is probably not the same bit of code of which runs stuff from the command line.

Without knowing what distribution of Linux this is / what non-standard configurations have been applied we can't advise how to install the appropriate version of PHP / determine the location of an existing installation.