This tutorial assume that you know how to create/open AWS EC2 instance. In case you are not aware of this, Please Click Here
- ...with either curl or wget.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
- The script clones the nvm repository to
~/.nvm
and adds the source line to your profile (~/.bash_profile
,~/.zshrc,
~/.profile,
or~/.bashrc
). (You might want/need to add the source loading line by yourself, if the automated install tool does not add it for you.)export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
source ~/.bashrc
- (Another option is to open a new Terminal window/tab.)
- To verify that nvm has been installed, do:
command -v nvm
nvm ls
nvm install v8.9.4
nvm install v9.6.1
8) create a new file server.js to test node app.
const http = require('http');save the file and run the following command. Make sure you are in the folder where script is placed
http.createServer( (request, response) => {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);'
console.log('Server running at http://127.0.0.1:8124/');
node server.js
9)
Server running at http://127.0.0.1:8124/
10) Last and final step is to add 8124 port in allowed list of security group for the instance where nodejs is installed. for more details Click Here.
11) open the webbrowser and open the URL http://127.0.0.1:8124/. replace 127.0.0.1 with your server's IP.
If you can see following, grab a cup of coffee and relax. Nodejs is installed properly.
No comments:
Post a Comment