PHP和node.js可以在同一服务器上运行 [英] can PHP and node.js run on the same server

查看:425
本文介绍了PHP和node.js可以在同一服务器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,后端有Apache和PHP.我正在通过许多新功能对其进行增强,并正在考虑将node.js用于新工作.

I have a web application with Apache and PHP on the back end. I am in the process of enhancing this with many new features and considering using node.js for the new work.

首先,PHP和node.js是否可以存在于同一台机器上?我不明白为什么不这样做. 其次,我可以直接从Javascript直接调用node.js代码并返回JSON吗?

First of all, can PHP and node.js co exist on the same machine? I do not see why not. Second, can I just call node.js code directly from Javascript and return JSON back?

推荐答案

是的,是的. Node和Apache/PHP可以共存于单个服务器上.

Yes, and yes. Node and Apache / PHP can co-exist on a single server.

您可能会遇到的唯一问题是,它们不能同时在相同的端口上收听.默认情况下,HTTP运行在端口80上,并且任何时候都只能在一个端口上监听"一个进程.因此,您可能必须在其他端口(例如8080)上运行Node应用程序,如果您的任何目标用户仅限于端口80,这可能会带来麻烦.

The only issue you are likely to run into is that they cannot both listen on the same port. HTTP, by default, runs on port 80 and only one process can "listen" on a single port at any one time. You may therefore have to run the Node app on a different port (for example, 8080), which could bring in difficulties if any of your target users are restricted to only port 80.

这篇关于PHP和node.js可以在同一服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆