【发布时间】:2018-07-01 12:26:11
【问题描述】:
我尝试在云服务器上运行最简单的 Express 代码
var express = require('express');
var app = express();
app.get('/test', (req, res) => res.send('Hello '));
app.listen( 3000 );
我收到 Apache 404 错误:GET /cood180119/projExpress1/demo1/test HTTP/1.0,无法获取 /cood180119/projExpress1/demo1/test
我注意到我的网址是http://77.xx.xx.xx/cood180119/projExpress1/demo1/test
虽然错误日志显示 IP : 88.xx.xx.xx。
如何解决?
我有一个 node hello world 示例,它使用以下 url:
http://77.xx.xx.xx/node-hello-world-master/
文件在public_html/node-hello-world-master/app.js中的位置,
const http = require('http');
http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end("Hello, World!\n port= ' + process.env.PORT);
}).listen(process.env.PORT); //is says that port is undefined
我在环境节点变量中设置了端口=3000。 在此之后,我可以得到端口号回显,但我仍然无法使用 ttp://77.xx.xx.xx:3000/ 访问网页
似乎防火墙配置错误。
【问题讨论】:
标签: node.js apache express http-status-code-404