Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Naxon's avatar
Level 6

Running socket.io server on shared hosting with ssh access

Hi,

I have a VPS server with DirectAdmin installed, hostname would be hostname.com for example.

I created an account with the domain socket.hostname.com . Now I want to create a running node.js server with socket.io so I'll be able to create a chat application using Laravel calling and sending requests to this socket.io server .

How do I do that?

0 likes
3 replies
JeroenVanOort's avatar

The socket.io server will need a port to bind to, which is 80 or 443 in most cases, because other ports can be blocked by client firewalls. Since DirectAdmin will already make it's web server (Apache) run on those ports, you can't run anything else on them as far as I know. If you're just playing around, use a random port number and you won't even need to configure anything in DirectAdmin for the socket server, but if you're planning on building a real life application, I'd recommend to seek or await further advise.

Naxon's avatar
Level 6

is there a tutorial for running binding to a certain port?

willvincent's avatar

If the node server is written correctly it will usually accept an optional port parameter when you launch the process. And/or there would be a config file. I've done them both ways.

The sort story is that the listen method would be passed the desired port and optionally hostname to listen on..

for example:

var server = app.listen(config.port, config.host, function() {
  console.log('Server listening at http://%s:%s', config.host, config.port);
});

You could set these as environment variables and then assign them to the config object like this:

if (process.env.NODE_HOST) {
  config.host = process.env.NODE_HOST;
}
if (process.env.NODE_PORT) {
  config.port = process.env.NODE_PORT;
}

It can be easier to setup any necessary config in a yaml file, then with the read-yaml node module, you can do this:

var config = yaml.sync('config.yml');

Also worth noting, aside from apache/nginx/whatever already being bound to 80 and/or 443, unless you're root (or have sudo access) you can't bind to a port <= 1024. So you'd have to choose a port number between 1025 and 65535.

Please or to participate in this conversation.