Skip to content

Instantly share code, notes, and snippets.

@merajsiddiqui
Created April 5, 2016 14:50
Show Gist options
  • Save merajsiddiqui/0174686cd0c20c384e2de40419da6d23 to your computer and use it in GitHub Desktop.
Save merajsiddiqui/0174686cd0c20c384e2de40419da6d23 to your computer and use it in GitHub Desktop.
Download NodeJs Source Code
wget https://nodejs.org/dist/v4.4.2/node-v4.4.2.tar.gz
Extract Tar file
tar -xvf node-v4.4.2.tar.gz
Move to Extracted Folder to install
cd node-v4.4.2/
Addons Before Installation needed
make
sudo apt-get install make
Essential
sudo aptitude install build-essential
Installing nodejs now
./configure && make && sudo make install
carefull you will see lot of creepy things on screen
check if node is successfully installed by checking node version
node -v
//Open the port whichever you want to use for your development prpose
eg mine is 8083
Test your working server
make any directory and make a file index.js in that directory
-- Paste the following code in index.js
--code start --
var http = require('http');
var handleRequest = function(request, response){
response.writeHead(200, {'Content-Type' : 'text/plain'});
response.end("Welcome to Node Essential Training");
};
var server = http.createServer(handleRequest);
server.listen(8083);
--code end--
Note the Port
start node server by
node index.js
Note Your Public DNS from Amazon and open that in browser foollwed by :8083 (:your port)
But till now as you will close your terminal your server will be down
--To solve ths issue --
nohup node index.js &
--It will create a nohup.out you can delete this not an issue --
Note:
But yoou have to type the port and you can not define port 80 as it needs sudo permmission which is not best fit for security issue
Get Rid of Port number in browser
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment