0
socket.io 웹 사이트의 간단한 채팅 자습서를 사용하여 nodejs 및 socket.io가있는 서버를 설정했지만 함께 사용할 수 있기를 원했습니다. 나의 기존 웹 페이지. php가 있고 .php 파일입니다. .html을 .php로 변경했을 때, html 파일처럼 PHP 파일을로드 할 수 없었습니다. 나는 얻는다 : 오류 : ENOENT, stat '/index.php'어떤 아이디어?Nodejs 및 socket.io index.html 대신 index.php 사용
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendfile('index.php');
});
io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
편집 : 위 코드에서 "index.html"을 "index.php"로 변경하는 것을 잊었으니 이제는 정확합니다.
링크가 도움이되었습니다. – Blubberguy22