How can i integrate php with my Http-server? [dupl

2019-09-06 19:15发布

问题:

This question already has an answer here:

  • Call PHP from virtual/custom “web server” 2 answers

Hi i've coded a web server using C language , a server just like apache or lighthttpd. it does listenings on port 80 and manipulates with GET & POST requests, i may handle text/html files, but my question here : how can i integrate PHP compiler with it so i would be able to handle php scripts in my http-server, thank you in advance !

回答1:

I think the easiest way would be to run it as a system call.

You can get documentation here.

You will have to set the $_SERVER variables as environment variables for the call from values gleaned from the request header but then it should just be a matter of piping in the request body and returning STDOUT.

you should be able to do something similar to support other server side languages as well (python, ruby etc..)