dongyutan1703
dongyutan1703
2012-07-24 15:29

如何将Node.js服务器连接到Apache服务器?

  • node.js
  • apache
  • websocket
  • php
  • javascript

I'd like to use Socket.io and Node.js to do push notifications. The end goal is to do something similar to what Stackoverflow does with their commenting to notify people of new comments.

My site is in PHP and runs on Apache on an EC2 instance. I've heard that Apache doesn't handle concurrency well so I'm interested in using Node to handle the hopefully large # of simultaneous, persistent connections. I guess there are two solutions:

  1. Put Node on same instance as Apache and proxy the two servers
  2. Put Node on a separate instance

In either case, I don't know how the connection between these two servers looks programmatically. For example, while WebSockets/Node handles the sending/receiving of messages, I need to store these messages in my MySQL database and that would require some PHP code, yes/no? Also, how is the message received on my PHP page? Via a $.post to a url like this, http://mysite/receiver.php that would be resolved by my Apache server?

I'd be happy to see either comments or code to help me understand this better.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐

换一换