관리 메뉴

캐나다 전산실 근무자

[리눅스 환경] How to install Node.js on a VPS or a Dedicated server (e.g. 김치하우스 캘거리) 본문

개발관련-이것저것

[리눅스 환경] How to install Node.js on a VPS or a Dedicated server (e.g. 김치하우스 캘거리)

모데라투스 2020. 10. 26. 12:54

아시는 분의 Portfolio 용 사이트를 공동 작업하는 과정에서, Apche 와 Node.js를 연동해야 하는 상황 발생


1. Node 와 npm 버전 확인
 a) node --version : v12.19.0
 b) npm --version : 6.14.8

2. Node.js apps 실행

 - To run a Node.js application that is production-ready and has a package.json file included,
    you can use the following command:
   nohup npm start --production &
   --> 여기서 nohup 명령어는 HUP 시그널을 무시시켜서 백그라운 프로세스 실행을 가능하게 한다고 한다.

 - Node.js app 이 packag.json 파일을 포함하고 있지 않는 경우에는:
  nohup node my_app.js &

 

3. Connect your Website with a Running Node.js App
- 김치하우스 웹사이트는 VPS에 호스팅되어 있는데, cPanel 이라는 web hosting control panel이 제공되고 있다.
  cPanel 상에서 설정 파일을 수정하는 방법을 구글링 해서 찾아야 했다.

  1) Go to File Manager --> public_html folder
  2) Hidden file 볼 수 있게 설정 확인

     - Setting buton on the upper-right

  3) .htaccess file 수정 : replace XXXXX with the port your Node.js application is working on.
        DirectoryIndex disabled
        RewriteEngine On RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]

 

4. How to stop an appplication
pkill node

 

 

출처: www.namecheap.com/support/knowledgebase/article.aspx/10202/48/how-to-install-nodejs-on-a-vps-or-a-dedicated-server

 

'개발관련-이것저것' 카테고리의 다른 글

배경- Modern Javascript  (0) 2020.12.24
Github opensource 참여하기  (0) 2020.07.30
Writing Meaningful Git Commit Messages  (0) 2019.02.20
Web API  (0) 2019.01.08
SourceTree 에서 특정 파일 커밋 제외시키기  (0) 2018.06.20
Comments