티스토리 뷰

 

 


1. nvm을 사용한 node.js 설치

 

nvm? Node Version Manager.


#1. nvm을 이용한 설치

 

 

(1) nvm 설치

 

> 아래 명령어중 하나를 선택하여 설치 진행

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

# 또는 

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

 

> curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

[root@discord-bot-test ~]# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13527  100 13527    0     0  16562      0 --:--:-- --:--:-- --:--:-- 16556
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
remote: Enumerating objects: 290, done.
remote: Counting objects: 100% (290/290), done.
remote: Compressing objects: 100% (257/257), done.
remote: Total 290 (delta 35), reused 97 (delta 20), pack-reused 0
Receiving objects: 100% (290/290), 163.27 KiB | 0 bytes/s, done.
Resolving deltas: 100% (35/35), done.
=> Compressing and cleaning up git repository

=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

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
[root@discord-bot-test ~]#



# bash profile 적용
[root@discord-bot-test ~]# source .bash_prrofile

 

 

(1) node.js 설치

 

> 버전을 지정하여 설치 (본인의 경우 Local에 12.15버전이 설치되어있어서 동일하게 설치함)

[root@discord-bot-test ~]# nvm install v12.15.0
Downloading and installing node v12.15.0...
Downloading https://nodejs.org/dist/v12.15.0/node-v12.15.0-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v12.15.0 (npm v6.13.4)
Creating default alias: default -> v12.15.0
[root@discord-bot-test ~]#

 

> 설치 후 버전 확인

[root@discord-bot-test ~]# node -v
v12.15.0
[root@discord-bot-test ~]# npm -v
6.13.4
[root@discord-bot-test ~]#

 

(2) 외부 접근을 위한 Port 허용

 

> Nodejs에서 사용할 포트를 추가하기 위함.

기본적을 3000번 포트를 사용하며 본인이 앞으로 사용할 포트를 추가하면 됨.

 

시작에 앞서 현재 허용중인 포트 상태 확인

[root@discord-bot-test ~]# iptables -L -v

Chain INPUT (policy ACCEPT 117 packets, 8050 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:hbci
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:hbci
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:rfb

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination


Chain OUTPUT (policy ACCEPT 90 packets, 21052 bytes)
 pkts bytes target     prot opt in     out     source               destination

 

> 적용 및 확인

[root@discord-bot-test ~]# firewall-cmd --zone=public --add-port=3000/tcp --permanent
success
[root@discord-bot-test ~]# firewall-cmd --reload
success
[root@discord-bot-test ~]# firewall-cmd --zone=public --list-all
public
  target: default
  icmp-block-inversion: no
  interfaces:
  sources:

  services: dhcpv6-client ssh
  ports: 3000/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@discord-bot-test ~]#

 

 

<에러 대응> 만약 다음과 같은 에러가 발생할 경우?

- firewalld가 inactive 상태임.

[root@discord-bot-test ~]# firewall-cmd --zone=public --add-port=3000/tcp --permanent
FirewallD is not running

[root@discord-bot-test ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

   Active: inactive (dead)
     Docs: man:firewalld(1)

> 설치 확인

[root@discord-bot-test ~]# yum list installed firewalld
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.navercorp.com
 * extras: mirror.navercorp.com
 * updates: mirror.navercorp.com

Installed Packages
firewalld.noarch                                                  0.6.3-2.el7_7.3                                                  @updates

> 실행 & 상태 확인

[root@discord-bot-test bin]# systemctl enable firewalld
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.

[root@discord-bot-test ~]# systemctl start firewalld

[root@discord-bot-test bin]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

   Active: active (running) since Tue 2020-03-10 19:37:04 KST; 6s ago
     Docs: man:firewalld(1)
 Main PID: 6021 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─6021 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

Mar 10 19:37:03 discord-bot-test systemd[1]: Stopped firewalld - dynamic firewall daemon.
Mar 10 19:37:03 discord-bot-test systemd[1]: Starting firewalld - dynamic firewall daemon...
Mar 10 19:37:04 discord-bot-test systemd[1]: Started firewalld - dynamic firewall daemon.

 

 

(3) 기타. nCloud에서 서버를 생성 후 공인IP를 이용하는 사용자일 경우?

> ACG에 3000포트 추가해줄것.


#2 확인

 

[root@discord-bot-test bin]# node www
GET / 200 44.541 ms - 223
GET /stylesheets/style.css 200 15.701 ms - 111
GET /favicon.ico 404 38.316 ms - 1083

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함