Nodejs, expressjs serving PHP files

Ok, I played with nodejs, expressjs and socket.io to create some applications. But now I come to the stage where I want to work a little.

I noticed several node applications using PHP for twitter auth on my client side. When I try to rename the client.html file to client.php and restart the server, it produces a blank page with this

Cannot GET / 

How will php files be served or will I do twitter auto using js?

This is my NodeJS server.js

 var http = require('http'), express = require('express'); var app = module.exports = express.createServer(); // Configuration app.configure(function(){ app.use(express.static(__dirname + '/public')); }); app.listen(1234); console.log("server started on port :1234"); 
+4
source share
3 answers

As already noted, node.js itself will not interpret php files for you. The following options are available:

  • there is nginx in front of node and reverse proxy all the requests that you want to process in node from it
  • proxy php requests from node to server with php support
  • run php process for every request in node
  • make a fastcgi link to php-fastcgi using the node fastcgi parser
+7
source

Uh, skip PHP completely and integrate everyauth into your application.

+4
source

PHP-EXPRESS should do. Just install the package and follow the docs.

https://www.npmjs.com/package/php-express

+1
source

All Articles