Created
January 18, 2017 16:32
-
-
Save makkaba/bb296f9c2ae7b58a55fcc6641f5dd134 to your computer and use it in GitHub Desktop.
node.js 헬로월드
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(8080, 'localhost'); | |
console.log('Server running at http://localhost:8080/'); |
추가로 hello_express.js는 이렇게 테스트하면 되겠다.
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello Express')
})
app.listen(8080, function () {
console.log('Example app listening on port 8080!')
})
!아마존 ec2를 사용한다면 8080포트가 다 열려있어야 함!
pm2 실행 (production mode)
NODE_ENV=production pm2 start app.js
이렇게 해도 된다
config.yml
apps:
- script : index.js
watch : true
env :
NODE_ENV: production
env_production:
NODE_ENV: production
pm2 start config.yml
시스템 리부팅 시에도 pm2 프로세스가 작동되도록 하려면
pm2 startup 명령어를 마지막에 쳐줘야 함
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
이때의 nignx의 설정(sites-available)은 다음과 같다.
tutorial 참고
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
다른 블로그에서 본거
이거 또한 잘 됐다