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.


Type the following in your terminal

whereis php


I found the executables in /usr/bin/

eg:

  • /usr/bin/php
  • /usr/bin/php7.0
  • /usr/bin/php7.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:

  • https://www.rfc-editor.org/rfc/rfc3875
  • http://en.wikipedia.org/wiki/Common_Gateway_Interface