Linux – Where is the PHP executable on Ubuntu

apache-http-serverlinuxPHPUbuntuubuntu-8.10

I have installed Apache and PHP. I know PHP works as I have tested a simple PHP file on an Apache server.

I'm writing a simple webserver which should be able to process PHP files. So once I get a request for a PHP file, I want to do something like 'exec php test.php' and get the output and pass it to the client.

As I'm not much into Ubuntu, I don't know where the PHP executable is (should be in \bin right?) to do it. But there is no PHP file inside \bin or \usr\bin.

When I run 'which php' it shows nothing. How do I do this?

Best Answer

You need to install the php5-cli or php5-cgi package.

sudo apt-get install php5-cli
# OR
sudo apt-get install php5-cgi

As Zoredache noted in the comment. cli version doesn't process headers nor dos output them - it's sort of clean PHP interpreter completely unaware of HTTP.

If you want version capable of above mentioned, use the CGI version.

Related Question