Install and Run node.js on a server

For discussions about game development that does not fit in any of the other topics.
Post Reply
JetPro
Posts: 15
Joined: Mon Apr 29, 2013 8:37 am

Install and Run node.js on a server

Post by JetPro »

Hello, everyone. This is actually my first day of being a member of this great forum. I have found out about this forum from hallsofvallhalla's YouTube tutorials regarding node.js.

I have watched the entire series of his tutorial for beginners in node.js development. He has taught well and I followed everything that he demonstrated. I have implemented node.js and socket.io using WAMP (localhost) after following instructions from his video tutorials.

The problem is, I do not know how to install and run node.js on my remote server.
I have a personal hosting with 1 GB Disk Space and 10 GB Bandwidth, and it is provided by a local company here in the Philippines. Is this enough to install and run node.js and socket.io in my server? If it is, please state how.


Thank you.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Install and Run node.js on a server

Post by Chris »

The disk space and bandwidth aren't important. You need SSH or Telnet access for a Linux server. If it's running windows Remote Desktop will do.
Fighting for peace is declaring war on war. If you want peace be peaceful.
JetPro
Posts: 15
Joined: Mon Apr 29, 2013 8:37 am

Re: Install and Run node.js on a server

Post by JetPro »

Chris wrote:The disk space and bandwidth aren't important. You need SSH or Telnet access for a Linux server. If it's running windows Remote Desktop will do.
Oh. Sorry, but I do not know much about networking. I also do not know what operating system are my servers running.

ADD: I asked my provider, they are using Linux CentOS.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Install and Run node.js on a server

Post by Chris »

Is it a shared hosting package or a VPS? Do you have SSH access? What operating system are you running on your local machine?
Fighting for peace is declaring war on war. If you want peace be peaceful.
JetPro
Posts: 15
Joined: Mon Apr 29, 2013 8:37 am

Re: Install and Run node.js on a server

Post by JetPro »

This is a bit disappointing. I contacted my provider and asked them, my hosting is on a shared environment and it's not running SSH.

I was planning to use node.js and socket.io in my project, but it seems like it's impossible to do it with my server features. Do you have any alternative ways to create an interaction between two players in an HTML5 based game? It's a card game that has interaction between a maximum of two players, but it may have a tons of players playing at the same time. I want to avoid spamming on my server.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Install and Run node.js on a server

Post by Chris »

Fighting for peace is declaring war on war. If you want peace be peaceful.
JetPro
Posts: 15
Joined: Mon Apr 29, 2013 8:37 am

Re: Install and Run node.js on a server

Post by JetPro »

Thank you, Chris!

This is great. For now, I will take time to read about this PHP WebSockets.
JetPro
Posts: 15
Joined: Mon Apr 29, 2013 8:37 am

Re: Install and Run node.js on a server

Post by JetPro »

Here's the second step of the procedure from the link that you have given me.
From the command line, run the server.php program to listen for socket connections.
It still needs a command line to run a server.php program and listen for socket connections. I am on a shared hosting and I don't have a direct access on the remote server that I am using. Will it still be possible for me to use this?
Last edited by JetPro on Mon Apr 29, 2013 10:53 am, edited 1 time in total.
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Install and Run node.js on a server

Post by Chris »

This script should be able run your server.php script as the user "Apache" on the server.

Code: Select all

$serverResult = `php server.php`;
echo $serverResult;
The `'s allow you to run things from the shell. You can also use the function shell_exec().

You might be able to get root access to the server using sudo.

Code: Select all

echo `su -h`;
Check to see what that returns. If it prompts for a password you have to run as Apache. Otherwise your server is insecure enough to play around with.


http://www.php.net/manual/en/function.s ... .php#68685
If you want to execute shell commands as root theres another workaround.

Code: Select all

<?php
shell_exec('sudo -u root -S command_goes_here < /home/$User/dir/dir/dir/passfile');
?>
It will readout the file 'passfile' that you've hidden under quite some dirs (to make it a bit less insecure) and use the content as password to login as root.

Note that storing your root password is far from secure but it's an easy way to execute commands under root in controlled environments.

Nathan De Hert
Fighting for peace is declaring war on war. If you want peace be peaceful.
JetPro
Posts: 15
Joined: Mon Apr 29, 2013 8:37 am

Re: Install and Run node.js on a server

Post by JetPro »

I tried to run this:

Code: Select all

echo `su -h`;
It did not return anything, it is not also requiring a password. It just displayed a plain webpage with no content.

Code: Select all

<?php
shell_exec('sudo -u root -S command_goes_here < /home/$User/dir/dir/dir/passfile');
?>
I do not understand any of this code.
Post Reply

Return to “General Development”