0
我哈瓦與node.js的簡單的HTTP服務器無法正常工作
的盒上openshift的帳戶,這是我server.js
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello Http');
});
server.listen(process.env.OPENSHIFT_NODEJS_PORT || 3000);;
這是的package.json文件
{
"name": "OpenShift-Sample-App",
"version": "1.0.0",
"description": "OpenShift Sample Application",
"keywords": [
"OpenShift",
"Node.js",
"application",
"openshift"
],
"author": {
"name": "OpenShift",
"email": "[email protected]",
"url": "http://www.openshift.com/"
},
"homepage": "http://www.openshift.com/",
"repository": {
"type": "git",
"url": "https://github.com/openshift/origin-server"
},
"engines": {
"node": ">= 0.6.0",
"npm": ">= 1.0.0"
},
"dependencies": {
"express": "~3.4.4"
},
"devDependencies": {},
"bundleDependencies": [],
"private": true,
"main": "server.js"
}
和應用程序在本地主機上工作node server.js
。問題是什麼?
日誌
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1135:5)
at Object.<anonymous> (/var/lib/openshift/5423abc786asbcbasd89c/app-root/runtime/repo/server.js:7:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
DEBUG: Program node server.js exited with code 8
DEBUG: Starting child process with 'node server.js'
新日誌說'ws'是必需的,我如何將lib添加到openshift?此外,我可以看到服務器消息在端口'80',但與端口'3000'只是請求被記錄了一次 – shampoo 2014-09-24 21:09:31
僅供參考,我刪除了'ws'我剛剛使用服務器:)它只能在端口'80'我試過'8080',這可能是一個安全問題嗎? – shampoo 2014-09-24 21:17:58