Socket.io chat, defining url

1

I would like a help with chat using socket.io, I would like to set a URL, I can not, I can only access through localhost: 3000.

For example, I wanted the chat to be on the home page of my site example: siteexample.com, how do I define this? 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, how do 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 ...

    
asked by anonymous 09.06.2016 / 13:21

1 answer

0

Answering your second question, if you are using an Apache server you will go to httpd.conf which is usually located in a + folder - so depending on your version: Installation path \bin\apache\apache2.4.18\conf .

You open the file, I usually open it with notepad and find a part of the file that says DirectoryIndex (not commented) and changes what is the front of the property to index.php or any other name with extension php .

    
25.08.2016 / 14:12