Apache和Node.js的同一台服务器上 [英] Apache and Node.js on the Same Server

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

问题描述

我要使用节点,因为它的快捷,使用我使​​用在客户端相同的语言,它的非阻塞的定义。但是,谁雇我写的文件处理程序(保存,编辑,重命名,下载,上传文​​件等)的家伙,他要使用Apache。所以,我必须:

I want to use Node because it's swift, uses the same language I am using on the client side, and it's non-blocking by definition. But the guy who I hired to write the program for file handling (saving, editing, renaming, downloading, uploading files, etc.), he wants to use apache. So, I must:


  1. 说服他使用节点(他上放弃小地)

  1. Convince him to use Node (he's giving up little ground on that)

图如何上传,下载,重命名,保存等文件节点或

Figure out how to upload, download, rename, save, etc. files in node or

我必须安装Apache和节点在同一台服务器上。

I must install apache and node on the same server.

这是最有利的形势,以及如何实现的?

Which is the most favorable situation, and how do I implement that?

推荐答案

问得好!

有很多网站和PHP实现免费的网络应用程序上运行Apache,很多人使用它,所以你可以混搭一些pretty容易,再说,提供静态内容的它是一个没有脑子的方法。 Node是速度快,功能强大,优雅,性感的工具,V8的原始动力,并没有内置依赖一台堆栈。

There are many websites and free web apps implemented in PHP that run on Apache, lots of people use it so you can mash up something pretty easy and besides, its a no-brainer way of serving static content. Node is fast, powerful, elegant, and a sexy tool with the raw power of V8 and a flat stack with no in-built dependencies.

我也想的Apache的易用性/灵活性,但Node.js的的咕噜与优雅,的为什么不能我有两个的?

I also want the ease/flexibility of Apache and yet the grunt and elegance of Node.JS, why cant I have both?

幸运与的ProxyPass 在Apache httpd的指令.conf文件它不是太难管在一个特定的URL到您的Node.js应用程序的所有请求。

Fortunately with the ProxyPass directive in the Apache httpd.conf its not too hard to pipe all requests on a particular URL to your Node.JS application.

ProxyPass /node http://localhost:8000/

另外,确保以下行没有被注释掉,所以你得到正确的代理服务器和子模块重新路由HTTP请求:

Also, make sure the following lines are NOT commented out so you get the right proxy and submodule to reroute http requests:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

然后在8000端口上运行你的应用程序的节点!

Then run your Node app on port 8000!

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Apache!\n');
}).listen(8000, '127.0.0.1');

然后你可以使用你的网址 /节点/ 路径访问所有Node.js的逻辑,网站的其他部分可以留给Apache来承载您现有的PHP网页:

Then you can access all Node.JS logic using the /node/ path on your url, the rest of the website can be left to Apache to host your existing PHP pages:

现在剩下的就是说服你的托管公司,让你的这个配置!!!运行

Now the only thing left is convincing your hosting company let your run with this configuration!!!

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

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