PHP/CGI how to make it work under Resin standalone?

David Yutzy

tumbleweed and gunslinger
Ranch Hand

Posts: 192

posted 14 years ago

I've read on the Caucho site about various people trying to get PHP and CGI to work under Resin and use something called "FastCGI" within Resin to get it working. I've also tweaked some code to get PHP and CGI working on a RedHat box, but the same code doesn't work on Windows at all. Have anyone got this to work, if so, could yo post what I need to get it working under Resin? The main push for me is I would like to run Resin as my sole web server, rather than having Apache handle PHP/CGI and Resin Java. I don't have the bandwidth nor need to have to deal with two web servers. I do a lot of side projects and virtual hosting causes me to have to setup Apache as well as Resin to handle the differing requests.

You may or may not want to use that method; that's why Resin has FastCGI support. If you look at that page, you'll see that PHP calls chdir(), which may or may not mess up your server depending on whether you use File() and FileInputStream() assuming the current directory. The FastCGI requires you to compile PHP with something like --fast-cgi as a ./configure option. Then you also need a launching program to get it to listen to the proper port. On Unix, Resin has as bin/fastcgirunner.pl script which will launch it. Then you can use Resin's FastCGIServlet to connect to the PHP process. Yes, it's a little more involved to set that up. If you don't care about performance, you can also just use the CGIServlet to invoke PHP as a normal CGI.