如何在Linux服务器上的端口80上启动node.js? [英] How to start node.js on port 80 on a linux server?

查看:256
本文介绍了如何在Linux服务器上的端口80上启动node.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在端口80上启动节点时,该错误告诉我该端口正在使用中.我想那是Apache.

When I try to start node on port 80, the error tells me that the port is in use. I imagine that's Apache.

接管"端口80并在服务器重新启动后保持该端口的正确方法是什么?

What is the proper way to "take over" port 80, and keep it that way after a server restart?

(Linux xxxx. _ _.com 2.6.32-5-amd64#1 SMP Tue Jun 14 09:42:28 UTC 2011 x86_64 GNU/Linux)

(Linux xxxx.__.com 2.6.32-5-amd64 #1 SMP Tue Jun 14 09:42:28 UTC 2011 x86_64 GNU/Linux)

推荐答案

您可以使用ip表将端口80映射到8000

you can use ip tables to map port 80 to 8000

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8000

使其永久化

sudo sh -c "iptables-save > /etc/iptables.rules"

并添加

pre-up iptables-restore < /etc/iptables.rules

到您的/etc/network/interfaces

to your /etc/network/interfaces

这篇关于如何在Linux服务器上的端口80上启动node.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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