Do you have a dream of seeing your nodeJS application running on a live server?
But all such dreams ended up in a nightmare because you don't know anything about how to use a remote machine? And the dream remains a dream throughout your lifetime.
If so then I have my empathy for you because I had been sharing the same nightmare a few days ago ever since when a friend of mine made this simple and made me took a step ahead.
Let me make it
Prerequisites:
- Make sure you have a running remote machine in Ubuntu14.04, say EC2 instance. If you don't know how to set up a remote machine I promise I will help you up in my upcoming posts.
- You have an established connection to the remote machine. So that you can access your remote machine. You can use any client say Putty or directly the ssh command. Will surely post about this well.
Here are some very simple bullets points to set up a node application:
After you successfully connected to the remote server, you must be seeing something like this on your
terminal.
Now start following these points
1) Update Advance packaging tool
2) Install npm
3) Install nvm :
- sudo wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | sudo bash
- Re-start the terminal
- nvm install v9.2.0
- more details
4) Install git
5) Install babel-cli
sudo npm install -g babel-cli
6) Install MongoDB: details in my next post Also to run an application in port 80, you need to run the application with sudo, since only a super user can access ports below 1024.
7) git clone the repo and start with babel-node server.js
8) Run the application in background (In case of remote server like an ec2 instance)
- Start a server :sudo nohup babel-node server.js 1>./log.txt 2>./err.txt &
- Stop a server : sudo kill $(sudo lsof -t -i:5000)
- Or by using screen:
- screen -S newSession
- screen -r
No comments:
Post a Comment