Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am in need of using PHP from the command line. When I type

php ....

The system says:

-bash: php: command not found

Now, I know for fact that PHP is up and running b/c it hosts my drupal site. I'm not sure how to find the program. I'm searching through the directories for the path without any success.

What am I missing?

I am using Ubuntu Linux.

I have the following packages installed:

php5                                            install
php5-common                                     install
php5-curl                                       install
php5-gd                                         install
php5-mcrypt                                     install
php5-mysql                                      install
share|improve this question

migrated from Aug 22 '11 at 16:25

This question came from our site for professional and enthusiast programmers.

What is the output from whereis php? – Nobody Aug 22 '11 at 15:08
Which server OS are you using? Which package-manager are you using? – hakre Aug 22 '11 at 15:11
up vote 9 down vote accepted

Probably you need to install the CLI (command line interpreter) package. In Ubuntu or Debian this can be done via apt-get install php5-cli

share|improve this answer
How do you know he uses a system that has apt? – Nobody Aug 22 '11 at 15:07
It's pretty much the norm these days, and if the assumption is wrong then an edit can be made once the OP responds. – ridecar2 Aug 22 '11 at 15:09
How do you know the package is called php5-cli and not php-cli for example? – hakre Aug 22 '11 at 15:10
Don't speculate, let the OP respond. But as an indicator he tagged this question with php5 – akirk Aug 22 '11 at 15:11
There's the correct answer then. – ridecar2 Aug 22 '11 at 15:21

Most distributions split mod_php (the Apache module) and the PHP command line executable into separate packages. You will need to find the CLI package and install it.

share|improve this answer

If you believe that php is already on the system you can try

locate php

to find the program.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.