This is going to take some time so be patient.
Yum package manager have no direct node.js or node repository so you need to manually download and compile the node.js binary package. This step will take some time so make sure you grab a coffee before starting.
1 : Install GCC++ and Make.
2 : Install openssl-dev.
3: Install git
Execute these commands one by one and then run following.
1 : Download latest version of Node.js
Switch to node folder.
In order to install Node.js, you need to switch to latest branch of it. Current stable version at the time of writing this tutorial is v0.12.2.
Run this command to switch to branch.
Run following command one by one.
Above steps will take around 10-15 minute to complete. Once done you should be able to use node.js in your Amazon EC2 system.
Install NPM :
Before installing any node modules in your system we need to add path where those modules should get installed. To do so, you need to edit sudoers file. Here is how to do so.
vi /etc/sudoers
Once VI editor is opened, find this line.
Once found, press “i” key to go in insert mode in VI and at the end of this line add following.
Or replace it with this.
In order to save your changes, press ESC key and type “wq” and hit ENTER in VI editor.
All right, let’s install NPM module.
1 : Clone the NPM.
2 : Install the NPM.
sudo make install
Wait for few minutes and you are done !
Say “Hello World”
Congratulations ! We have finally setup and install the Amazon EC2 and Node.js. It’s time to test the setup. Let’s create one simple project and print “Hello World”.
Create a new folder and switch to that folder. create package.json using VI and paste this code.
"name": "sample",
"version": "0.0.1",
"dependencies": {
"express": "^4.12.3"
}
}
Run
실행했는데 이런 에러가 나면 (if you met this installing error)
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm config set registry http://registry.npmjs.org/
이 명령줄을 실행한다
to install Express.
Create app.js file and paste following code.
var app = express();
app.get("/",function(req,res){
res.send("<h1>Hello from EC2</h1>");
});
app.listen(80);
Run this app using following command.
Make sure you use SUDO for it. Visit your public DNS and you should see screen like this.
Conclusion :
Amazon is one of the best cloud provides and above all they let us try their System for free. You can use it to host your project, blog, website or anything. We have covered almost everything you need to get started but there are still some configuration left like mapping domains to EC2 instance. Will cover it later.
ref : https://codeforgeek.com/2015/05/setup-node-development-environment-amazon-ec2/
ref : https://stackoverflow.com/questions/45884752/npm-err-code-unable-to-get-issuer-cert-locally
'서버(Server) > Aws' 카테고리의 다른 글
AWS Databases (RDS) (0) | 2018.05.16 |
---|---|
Network ACL(Access Control List) (0) | 2018.05.15 |
CDN(Content Delivery Network) 과 CloudFront (0) | 2018.05.13 |
Amazon CloudWatch 작동 방식 (0) | 2018.05.12 |
AWS : 프리티어사용시 요금 폭탄 막기, 사용량 , 요금 메일설정 (0) | 2018.05.12 |