node.js - 如何在 apache 服务器 8000 和 2000 端口运行 Node js?

标签 node.js linux apache lamp

我有两个使用 node js 的网站。我希望这个站点在我编写 example-site1.com 时运行 8000 端口,在我编写 example-site2.com 时运行 2000 端口。

当我只写 IP:8000 或 IP:2000 时,它是正确的。

如何设置配置?

最佳答案

var ports = process.argv.splice(2)

var server = http.createServer(function (request, response) { }); server.listen(ports[0], function () { console.log('服务器监听端口'+ports[0]);

Node app.js 端口

关于node.js - 如何在 apache 服务器 8000 和 2000 端口运行 Node js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52531394/

相关文章:

linux - sed : add a string in specific line

linux - 如何在 bash shell 脚本中启动两个线程?

python - 日志模块: too many open file descriptors

php - 未通过 as2 接收文件

css - @font-face 显示我导入的字体 .woff 和 .ttf 的 404 错误

javascript - RESTful 服务,Post 无法正确保存到数据库

node.js - npm 运行前缀 :css ERR

javascript - grunt-spritesmith 配置在 gruntfile.js 上无法正常工作

javascript - JavaScript 中的++ 运算符

apache - 如何在 zend 服务器中重新启动 apache