2
I would like a help with chat using socket.io, I would like to define a URL, I am not getting, I can only access through localhost:3000
.
For example I wanted the chat to be on the homepage of my website
example: siteexemplo.com.br
, how do I define it? how do I start server.js
inside the server?
My code:
SERVER.JS
var socket = require( './node_modules/socket.io' );
var express = require('./node_modules/express');
var app = express();
var server = require('http').createServer(app);
var io = socket.listen( server );
var port = process.env.PORT || 3000;
chat js.
var socket = io.connect( 'http://'+window.location.hostname+':3000' );
Another question, as I define my index, for PHP?
I made the change in the code below:
app.use(express.static(__dirname + '/'));
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.php');
});
But when you access the site, it automatically downloads the page...
Your server is apache?
– Miguel
Yeah, he’s an Apache...
– Yuri Rodrigues
I’ll see if I can help
– Miguel
If you understand English it helps: http://stackoverflow.com/questions/16573668/best-practices-when-running-node-js-with-port-80-ubuntu-linode
– Miguel
@Miguel And is it possible to run a Nodejs with apache server? Or run the socket.io on an apache server? At least in the hosting server I use I could not precisely this because of this limitation (as I was informed by the technical support).
– celsomtrindade
Cannot run Nodejs on shared servers as Nodejs requires shell access to which unsigned hosts do not provide.
– Vinicios Yals
What would be the option of making a chat then?
– Yuri Rodrigues