Closed gavinengel closed 8 years ago
||
Hi Gavin
Are you setting the cgiEngine to point to your installation of PHP?
Defaults is 'php-cgi' that must be in the path. use: sphp.cgiEngine='php'; or full path i necessary
It seem that you are not using php-cgi, but rather php as cli. I have not tested that configuration. There might be side effects (but not this one)
Please tell me if that solves you issue
Best regards Simon
Hi Gavin
You must install php-cgi for this example to work.
php (cli) has no HTTP header support and other features, that makes it unsuitable for a server.
Is there any good reason why it should be made compatible with the php (cli) version?
Please let me know if this helps.
Best regards Simon
Would fastcgi
work?
As I understand it, fastcgi is a deamon? If such you would need a stream to communicate with it. If that is what you need, you should have a look at one of the node fastcgi projects.
sphp works with the php-cgi version. I bet that it could be made to work with both other version, but I haven't done it.
Why would I use CGI instead of FastCGI? Isn't FastCGI, ummm, faster?
FastCGI is a method of invoking a CGI; A process manager that clones the php process when needed. sphp is a process manager too, but loads the process preemptively, and hold it until needed. While FastCGI are more "resource friendly" I expect that sphp has a faster responsetime on low to moderate load. (A benchmark test would be nice :c)
Speed is one reason for using sphp, Another is the way a request is transferred to php, enabling node session and websocket support. That is not possible with the FastCGI projects. (takes a "preburner" script to initialize php globals)
To merge those to approaches would be a natural evolution of this project. But I don't have the time right now. Should anyone wish to implement it, I would be happy to assist.
Please let me know if you solved the problem by installing php-cgi
On derbian: sudo apt-get install php5-cgi
Im having this same error. I guess I don't understand why I need php-cgi. Before I ran into this npm module I was running a php server like php -S localhost:3000, and that works like a charm. So I'm pretty sure I have Apache processing my php. Think Im at a dead end here.
You need the php-cgi version installed to use this module. The reason is that it is necessary to use this handler to achieve the specified functionality.
You can change the engine specifically:
sphp.cgiEngine='php';
Was that your question?
@paragi Hi, I get this same issue running on mac.
php-cgi is in the path and executes fine from the terminal:
php-cgi -v
PHP 7.1.3 (cgi-fcgi) (built: Mar 28 2017 21:57:37)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
But when accessing my index.php file from express server it executes this exception:
Steffans-Mac-mini:cloud-npm-php steffanhalvorsen$ npm run start
> cloud-npm-php@1.0.0 start /Users/steffanhalvorsen/Documents/npm/cloud-npm-php
> node ./bin/www
Unable to start worker:php-cgi
events.js:163
throw er; // Unhandled 'error' event
^
Error: spawn php-cgi ENOENT
at exports._errnoException (util.js:1034:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
If I switch from
sphp.cgiEngine='php-cgi';
to
sphp.cgiEngine='php';
I can access my index.php file without error, but it doesnt return anything, just an empty page, and my 'Hello world!' doesnt show up:
index.php:
<?php
echo "Hello World!";
Hi there! Any advice for me on this error, please?