Luk*_*rns 2 node.js port-80 http-server
我正在使用全新安装的 Centos 5.5。我已经安装了 Node 并且可以正常工作(我只是使用 Node —— 没有 apache 或 nginx。),但我不知道如何在端口 80 上创建一个简单的服务器。Node 正在运行并且正在侦听端口 80。我我只是使用演示应用程序:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(80, "x.x.x.x");
console.log('Server listening to port 80.');
Run Code Online (Sandbox Code Playgroud)
当我访问我的 IP 时,它不起作用。我使用 ifconfig 获得了我的 ipaddress。我尝试了不同的端口。所以一定有我遗漏的东西。
我需要在我的服务器上配置什么才能使其工作?我想在不安装 apache 或 nginx 的情况下执行此操作。
卢克
编辑——好的,我安装了 nginx 并启动它,看看它是否与 node 相关,我没有看到它的欢迎页面。所以它肯定与服务器有关。
我是否通过运行:ifconfig然后读取eth0下的inet addr 来正确检索 IP 地址?
归档时间: |
|
查看次数: |
19038 次 |
最近记录: |