Node-php is an npm package: https://www.npmjs.com/package/node-php#nodephp---run-wordpress-and-other-php-scripts-with-node
My problem: Up until now I only needed static html files for my webpage, which were delivered okay.
However, now I want to deliver a php file as well. If i simply try to send it like a static file a popup to save the file appears instead of displaying it. So i set up node-php which claims to be able to deliver php files correctly as well. But, it's not working.
How the webpage looks with the below code, going to either the html page or the php page
Either help to make node-php work, or another method to fix this are appreciated.
var express = require('express');
var php = require("node-php"); //Required by node-php
var path = require("path"); //Required by node-php
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.use("/", php.cgi("/usr/bin/php")); //Required by node-php
//LISTEN
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);
app.set('ip', process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1');
http.listen(app.get('port'), app.get('ip'), function () {
console.log('LISTENING!');
});
app.use(express.static('public'));
//SEND FILES
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
app.get('/phpfile', function (req, res) {
res.sendFile(__dirname + '/phpfile.php');
});