如何为Node.js,PHP和MySQL设置开发环境

I am working on a web app where some of the existing code is in PHP, but much of the new development is going to be in Node.js. The backend is MySQL. In the past I've used MAMP for the LAMP stack. However what would you suggest using as a local development environment for Node.js, PHP, & MySQL?

Thank you,

You can Node server on any port you want which is available using Node Express module

var app = require('express')();

var listener = app.listen(<Available_Port>, function(){
    console.log('Listening on port ' + listener.address().port); 
});

MAMP apache will run on 80 port by default, from where your php scripts will gets executed and Mysql on port 3306 by default

Several packages can help you serve PHP through Node, most notably the node-php packages (there's two of them, completely unrelated to each other but generally does the same job).

Here's a sample of Node serving WordPress using mkschreder's node-php:

var express = require('express');
var php = require("node-php"); 
var path = require("path"); 

var app = express();

app.use("/", php.cgi("/path/to/wordpress")); 

app.listen(9090);

console.log("Server listening!"); 

Ideally though, you should stick to either just Node or PHP. Node operates server-side, so does PHP. Putting PHP on a Node project makes Node redundant, and vice versa.

Further reading: