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

我正在开发一个Web应用程序,其中一些现有代码是在PHP中,但大部分新开发是 将在Node.js. 后端是MySQL。 在过去,我使用MAMP作为LAMP堆栈。 但是,您建议将哪些用作Node.js,PHP和&amp ;;的本地开发环境。 MySQL?</ p>

谢谢,</ p>
</ div>

展开原文

原文

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,

doudui6756
doudui6756 我会在不同的端口上运行Node.js和MAMP吗?
4 年多之前 回复
dqd22496
dqd22496 安装节点服务器,对于带节点的mysql,你只需要为nodejs安装mysql模块,对于php你已经有了MAMP
4 年多之前 回复

2个回答



您可以在任何使用Node Express模块​​可用的端口上节点服务器</ p>

 <  code> var app = require('express')(); 

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

MAMP apache </ strong>默认情况下将在 80 </ strong>端口上运行, 您的PHP脚本将在何处执行,默认情况下 3306 </ strong> Mysql </ strong> </ p>
</ div>

展开原文

原文

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



有几个软件包可以帮助你通过Node提供PHP,最值得注意的是node-php软件包(有两个 他们 ,完全无关,但通常做同样的工作。)</ p>

以下是使用 mkschreder的node-php :</ p>

  var express = require('express'); 
var php = 要求( “节点 - PHP”);

var path = require(“path”);

var app = express();

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

app.listen(9090);

console.log(“服务器监听!”);

</ code> </ pre>

理想情况下,您应该坚持使用 </ em>节点或PHP。 Node运行服务器端,PHP运行。 将PHP放在Node项目上会使节点冗余,反之亦然。</ p>

进一步阅读:</ p>

展开原文

原文

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:

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐