Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com 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

4 Answers 4

up vote 8 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
1  
How do you know he uses a system that has apt? –  Nobody Aug 22 '11 at 15:07
2  
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
2  
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

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

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

locate php

to find the program.

share|improve this answer

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

Your Answer

 
discard

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.