I found an old PC and i want to use it as a dedicated Node.js test machine.
Basically i wanna write my apps on a win machine then copy them over samba to the node folder and launch them via ssh. Later, I would add an upstart script and copy it with samba to the server so that when i reboot the app starts automatically every time.
- What do I need to install in order to properly run Node.js apps on my network on a dedicated Ubuntu server? Here is the list I came up with, please correct me if I'm wrong. Is there anything else?
- ssh
- samba (ftp or sftp should be the way to go but as it's a closed internal network and i have to access it from various os's samba is the simplest way to share files not considering security issues..most of the time i use a simple text editor)
- "basic ubuntu server" files?
- "LAMP" (?)
- node.js
- node package manager.
- how do i install the latest Node.js, npm, and the init files on Ubuntu server. I saw that there was no simple
sudo apt-get install nodejs npm
. - What kind of script do I need to launch my apps and where do i put them (prefer native scripts)?
EDIT
After some testing i'm at a good point now, and here is what i did:
- I installed ubuntu from a minimal CD
- when it comes to choose the packages i selected ONLY ssh & samba
- update the system
- install the dependencies that u need to run node.js
- install latest node from git
- setup samba in my case i created the folder /var/nodejs for the scripts
- put your testApp.js in the nodejs folder
- start your testApp.js from ssh. *it won't work
3-update the system
sudo apt-get update && sudo apt-get upgrade
4-dependancies
sudo apt-get install g++ curl libssl-dev apache2-utils git-core make
5-install node
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
6-setup samba sudo nano /etc/samba/smb.conf
[nodejs]
comment = nodejs
workgroup = WG
security = USER
path = /var/nodejs
server string =Node JS
browsable = yes
read only = no
writeable = yes
create mask = 0777
7-testApp.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(80, "192.168.0.1");
console.log('Server running at http://192.168.0.1:80/');
8-Now everything should run...but:
You can run nodejs only as administrator appending "sudo" in front of the launch command else as a normal user u don't have access to most of the ports under 1000.
A. How can i lauch my app on port 80 without using sudo?
And obviously if u launch you app with the command sudo node /var/nodejs/testApp.js
if u close the terminal the app will stop.
For that we use a init script.
After some reading i found that upstart is natively installed in ubuntu server and it's probably the best way to launch your apps.
B. I know u need to put the script into /etc/init/ with your appname and .conf extension.but how does that work?