자바스크립트 프로그램을 실행할 수 있는 환경
“node.js는 Chrome v8 javascript 엔진으로 빌드된 javascript 런타임이다.”
”Node.js는 자바스크립트 프로그램이 서버로서 기능하기 위한 도구를 제공하고, 자바스크립트 프로그램이 동작하는 환경” 을 의미한다.
curl -o- <https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh> | bash
wget -qO- <https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh> | bash
# rpm -Uvh <http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm>
# yum -y install npm
# nvm install nodejs or [node 버전 입력]
웹 서버 소프트웨어로, 가벼움과 높은 성능을 목표로 한다.
이미지, 동영상, 자바스크립트, HTML 등 다양한 문서를 제공하는 서버 시스템
웹 서버의 역할
$ sudo yum install yum-utils
$ sudo yum install nginx
vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
yum install -y nginx
vi /etc/nginx/conf.d/default.conf
server {
listen 53001;
#listen [::]:8080;
#server_name localhost; # 도메인 주소 넣는부분
root /usr/dist/; # 배포할 프로젝트 dist 경로
index index.html index.htm;
client_max_body_size 100M;
location / {
root /usr/dist;
index index.html;
try_files $uri $uri/ /index.html; #경로 탐색
}
location /graphql {
proxy_pass http://주소:54001/graphql;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
vi /etc/nginx/nginx.conf
worker_processes 1; ## master process 내부 worker process 수
events { ## 네트워크 동작방법 설정
worker_connections 1024; ## 하나의 work process는 설정한 수만큼 연결 가능
}
http {
include mime.types;
server {
listen 80;
location / {
root html;
index index.html index.htm;
}
}
}
user nginx; ## NGINX 프로세스가 실행되는 권한, root 권한은 보안상 위험함
worker_processes 2; ## Default: 1, CPU 코어 하나에 최소한 한 개의 프로세스가 배정되도록 변경 권장
worker_priority 0; ## 값이 작을 수록 높은 우선순위를 갖는다. 커널 프로세스의 기본 우선순위인 -5 이하로는 설정하지 않도록 한다.
# 로그레벨 [ debug | info | notice | warn | error | crit ]
error_log /var/log/nginx/error.log error; ## 로그레벨을 warn -> error로 변경함
pid /var/run/nginx.pid;
events {
worker_connections 1024; ## Default: 1024, 현 서버는 RAM 8GB라 상향조정
multi_accept off; ## Default: off
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
server_tokens off; ## 헤더에 NGINX 버전을 숨김 (보안상 설정 권장)
keepalive_timeout 65; ## 접속 시 커넥션 유지 시간
#gzip on;
include /etc/nginx/conf.d/*.conf; ## conf 붙은 모든파일을 불러오는부분
}
systemctl reload nginx
systemctl start nginx
proxy_pass
문법을 통해 이용이 가능합니다. ”/some/path/
로 들어온 url은 모두 http://www.example.com/link/
로 처리하라” 라는 의미로, 클라이언트의 요청을 특정 Url로 변환시키는 역할을 수행server {
listen 443;
server_name {도메인 주소 1} {도메인 주소 2};
ssl on;
ssl_certificate {공개키 경로};
ssl_certificate_key {개인키 경로};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
root {웹 루트 경로};
index index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80;
server_name {도메인 주소 1} {도메인 주소 2};
return 301 https://{도메인 주소};
}
sudo systemctl status nginx
// Restart ## 서버 중단 후 재가동
sudo service nginx restart
// Reload ## 서버 중단 없이 reload 시점 설정 파일만 다시 불러와 적용
nginx -s reload
reload // 설정 파일을 다시 불러오기
quit // 서버 shutdown
stop // 서버 즉시 중단
reopen // 로그 파일을 다시 열기
sudo nginx -t
# nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
# nginx: configuration file /etc/nginx/nginx.conf test is successful
// NGINX
cd /usr/share/nginx/html