16

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?

samsamara
  • 415

4 Answers4

20

Type the following in your terminal

whereis php

13

I found the executables in /usr/bin/

eg:

  • /usr/bin/php
  • /usr/bin/php7.0
  • /usr/bin/php7.1
Andrew
  • 399
11

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.

1

If you are writing your own web server you almost certainly want to install or build the CGI version of the PHP binary, and you will want to implement the CGI protocol in your web server. The CGI version has the required facilities to capture the GET/POST data.

See:

Zoredache
  • 20,438