我在阿里云上面用node.js + nginx搭建一个个人网站,但是每次访问都是‘welcom to nginx’提示
server.js文件
http.createServer(function(req, res){ const pathname = url.parse(req.url).pathname; console.log(pathname); switch(pathname){ case '': case '/':
index(req, res);break; default:
loadfiels(req, res, pathname);break;
}
}).listen(9000, '0.0.0.0');用pm2运行这个文件,启动成功了:

nginx 的配置
conf/servers的文件下面有一个web.conf文件
server { listen 80; server_name tonghuiflang.com; location / { proxy_pass http://127.0.0.1:9000;
}
}在conf/nginx.conf 和 conf/nginx.conf.default 的http最后 添加 include servers/*;
可是通过域名访问还是‘welcom to nginx’提示,在本地是没有问题的
白猪掌柜的
LEATH
随时随地看视频慕课网APP