Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have installed apache and php. I know php works as I have tested a simple php file on apache server.

I'm writing a simple webserver which should be able to process php files. So what I want to do is once I get a request for a php file, 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 is the php executable (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?

share|improve this question
1  
What happened is most likely that you got php in apache as php module (technically - a library not an executable binary that gets called externally), that's why you couldn't find the binary. This comment is meant to complete the answer, which tells you what needs to be done to get the php binary in your system but doesn't provide any reasons why it was missing. –  AnonymousLurker Nov 3 '12 at 9:32
    
If you are really running Ubuntu 8.10 like your tags suggest, you should understand Ubuntu 8.10 is extremely out of date. You really should upgrade ASAP. There is no security support for that release. –  Zoredache Nov 3 '12 at 9:49
    
@Zoredache yeah I know it's very old. But I'm not a Ubuntu user. I had the CD and I installed it, just for my assignment! :D –  user601L Nov 3 '12 at 11:16

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
yeah I just learned I need php-cli..:) –  user601L Nov 3 '12 at 8:20
    
Since he is writing a web server, he probably doesn't want the CLI version since that isn't going to be able to get the GET/POST data. –  Zoredache Nov 3 '12 at 9:50

If you are writing your own web server you almost certainly what 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:

share|improve this answer
    
I'm writing a simple web server with PHP and CGI support. For parsing php files, what I'm gonna do is 'exec /usr/bin/php file.php'. And you can run CGI scripts by parsing them to perl. Am I right? feasible? –  user601L Nov 3 '12 at 11:41
    
Uhm, no CGI hasnothing to do with perl. You really should read at least the wikipedia article. –  Zoredache Nov 3 '12 at 20:16

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.